Skip to content

Commit

Permalink
Squashed 'libs/editor/' changes from 69aaa8a..4832795
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maxme committed Feb 16, 2016
1 parent 097b51b commit 68c6f4c
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.webkit.JavascriptInterface;
import android.webkit.URLUtil;
import android.webkit.WebView;
import android.widget.ToggleButton;
Expand Down Expand Up @@ -59,6 +60,7 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli
private static final String ARG_PARAM_CONTENT = "param_content";

private static final String JS_CALLBACK_HANDLER = "nativeCallbackHandler";
private static final String JS_STATE_INTERFACE = "nativeState";

private static final String KEY_TITLE = "title";
private static final String KEY_CONTENT = "content";
Expand Down Expand Up @@ -366,13 +368,18 @@ private void setupFormatBarButtonMap(View view) {
}

protected void initJsEditor() {
if(!isAdded()) {
if (!isAdded()) {
return;
}

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

mWebView.addJavascriptInterface(new JsCallbackReceiver(this), JS_CALLBACK_HANDLER);
mWebView.addJavascriptInterface(new NativeStateJsInterface(getActivity().getApplicationContext()),
JS_STATE_INTERFACE);

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

Expand Down Expand Up @@ -1123,7 +1130,7 @@ private void updateVisualEditorFields() {
private void hideActionBarIfNeeded() {

ActionBar actionBar = getActionBar();
if (getActionBar() != null
if (actionBar != null
&& !isHardwareKeyboardPresent()
&& mHideActionBarOnSoftKeyboardUp
&& mIsKeyboardOpen
Expand All @@ -1138,8 +1145,8 @@ private void hideActionBarIfNeeded() {
private void showActionBarIfNeeded() {

ActionBar actionBar = getActionBar();
if (getActionBar() != null && !actionBar.isShowing()) {
getActionBar().show();
if (actionBar != null && !actionBar.isShowing()) {
actionBar.show();
}
}

Expand Down Expand Up @@ -1261,4 +1268,37 @@ private void applyFormattingHtmlMode(ToggleButton toggleButton, String tag) {
mSourceViewContent.setSelection(selectionEnd + endTag.length());
}
}

private class NativeStateJsInterface {
Context mContext;

NativeStateJsInterface(Context context) {
mContext = context;
}

@JavascriptInterface
public String getStringEdit() {
return mContext.getString(R.string.edit);
}

@JavascriptInterface
public String getStringTapToRetry() {
return mContext.getString(R.string.tap_to_try_again);
}

@JavascriptInterface
public String getStringUploading() {
return mContext.getString(R.string.uploading);
}

@JavascriptInterface
public String getStringUploadingGallery() {
return mContext.getString(R.string.uploading_gallery_placeholder);
}

@JavascriptInterface
public int getAPILevel() {
return Build.VERSION.SDK_INT;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ public class RippleToggleButton extends ToggleButton {
private Paint mStrokePaint;

public RippleToggleButton(Context context) {
super(context);
}
this(context, null);
}

public RippleToggleButton(Context context, AttributeSet attrs) {
super(context, attrs);
init();
this(context, attrs, 0);
}

public RippleToggleButton(Context context, AttributeSet attrs, int defStyle) {
Expand Down
10 changes: 9 additions & 1 deletion WordPressEditor/src/main/res/layout-w360dp/format_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_media"
android:background="@drawable/format_bar_button_media_selector"/>

<org.wordpress.android.editor.RippleToggleButton
android:id="@+id/format_bar_button_bold"
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_bold"
android:background="@drawable/format_bar_button_bold_selector"
android:tag="@string/format_bar_tag_bold"/>

Expand All @@ -52,6 +54,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_italic"
android:background="@drawable/format_bar_button_italic_selector"
android:tag="@string/format_bar_tag_italic"/>

Expand All @@ -60,6 +63,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_quote"
android:background="@drawable/format_bar_button_quote_selector"
android:tag="@string/format_bar_tag_blockquote"/>

Expand All @@ -68,6 +72,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_ul"
android:background="@drawable/format_bar_button_ul_selector"
android:tag="@string/format_bar_tag_unorderedList"/>

Expand All @@ -76,6 +81,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_ol"
android:background="@drawable/format_bar_button_ol_selector"
android:tag="@string/format_bar_tag_orderedList"/>

Expand All @@ -84,6 +90,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_link"
android:background="@drawable/format_bar_button_link_selector"
android:tag="@string/format_bar_tag_link"/>
</LinearLayout>
Expand All @@ -100,6 +107,7 @@
style="@style/FormatBarHtmlButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_html"
android:background="@drawable/format_bar_button_html_selector"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
10 changes: 9 additions & 1 deletion WordPressEditor/src/main/res/layout-w380dp/format_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_media"
android:background="@drawable/format_bar_button_media_selector"/>

<org.wordpress.android.editor.RippleToggleButton
Expand All @@ -39,6 +40,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_bold"
android:background="@drawable/format_bar_button_bold_selector"
android:tag="@string/format_bar_tag_bold"/>

Expand All @@ -48,6 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_italic"
android:background="@drawable/format_bar_button_italic_selector"
android:tag="@string/format_bar_tag_italic"/>

Expand All @@ -57,6 +60,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_quote"
android:background="@drawable/format_bar_button_quote_selector"
android:tag="@string/format_bar_tag_blockquote"/>

Expand All @@ -66,6 +70,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_ul"
android:background="@drawable/format_bar_button_ul_selector"
android:tag="@string/format_bar_tag_unorderedList"/>

Expand All @@ -75,6 +80,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_ol"
android:background="@drawable/format_bar_button_ol_selector"
android:tag="@string/format_bar_tag_orderedList"/>

Expand All @@ -84,6 +90,7 @@
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:contentDescription="@string/format_bar_description_link"
android:background="@drawable/format_bar_button_link_selector"
android:tag="@string/format_bar_tag_link"/>

Expand All @@ -99,6 +106,7 @@
style="@style/FormatBarHtmlButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_html"
android:background="@drawable/format_bar_button_html_selector"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
8 changes: 8 additions & 0 deletions WordPressEditor/src/main/res/layout-w600dp/format_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_media"
android:background="@drawable/format_bar_button_media_selector"/>
</LinearLayout>

Expand All @@ -47,6 +48,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_bold"
android:background="@drawable/format_bar_button_bold_selector"
android:tag="@string/format_bar_tag_bold"/>

Expand All @@ -55,6 +57,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_italic"
android:background="@drawable/format_bar_button_italic_selector"
android:tag="@string/format_bar_tag_italic"/>

Expand All @@ -77,6 +80,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_link"
android:background="@drawable/format_bar_button_link_selector"
android:tag="@string/format_bar_tag_link"/>
</LinearLayout>
Expand All @@ -91,6 +95,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_ul"
android:background="@drawable/format_bar_button_ul_selector"
android:tag="@string/format_bar_tag_unorderedList"/>

Expand All @@ -99,6 +104,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_ol"
android:background="@drawable/format_bar_button_ol_selector"
android:tag="@string/format_bar_tag_orderedList"/>

Expand All @@ -107,6 +113,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_quote"
android:background="@drawable/format_bar_button_quote_selector"
android:tag="@string/format_bar_tag_blockquote"/>
</LinearLayout>
Expand All @@ -121,6 +128,7 @@
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_html"
android:background="@drawable/format_bar_button_html_selector"/>
</LinearLayout>
</LinearLayout>
Expand Down
3 changes: 2 additions & 1 deletion WordPressEditor/src/main/res/layout/dialog_image_options.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

<ImageView
android:id="@+id/image_thumbnail"
android:contentDescription="@string/image_thumbnail"
android:layout_width="@dimen/image_settings_dialog_thumbnail_size"
android:layout_height="@dimen/image_settings_dialog_thumbnail_size"
android:layout_marginLeft="@dimen/image_settings_dialog_thumbnail_left_margin"
Expand Down Expand Up @@ -150,4 +151,4 @@
android:layout_marginLeft="@dimen/image_settings_dialog_input_field_start_margin"
android:visibility="gone"/>
</LinearLayout>
</ScrollView>
</ScrollView>
10 changes: 9 additions & 1 deletion WordPressEditor/src/main/res/layout/format_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_media"
android:background="@drawable/format_bar_button_media_selector"/>

<org.wordpress.android.editor.RippleToggleButton
android:id="@+id/format_bar_button_bold"
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_bold"
android:background="@drawable/format_bar_button_bold_selector"
android:tag="@string/format_bar_tag_bold"/>

Expand All @@ -57,6 +59,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_italic"
android:background="@drawable/format_bar_button_italic_selector"
android:tag="@string/format_bar_tag_italic"/>

Expand All @@ -65,6 +68,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_quote"
android:background="@drawable/format_bar_button_quote_selector"
android:tag="@string/format_bar_tag_blockquote"/>

Expand All @@ -73,6 +77,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_ul"
android:background="@drawable/format_bar_button_ul_selector"
android:tag="@string/format_bar_tag_unorderedList"/>

Expand All @@ -81,6 +86,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_ol"
android:background="@drawable/format_bar_button_ol_selector"
android:tag="@string/format_bar_tag_orderedList"/>

Expand All @@ -89,6 +95,7 @@
style="@style/FormatBarButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_link"
android:background="@drawable/format_bar_button_link_selector"
android:tag="@string/format_bar_tag_link"/>
</LinearLayout>
Expand All @@ -106,6 +113,7 @@
style="@style/FormatBarHtmlButton"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:contentDescription="@string/format_bar_description_html"
android:background="@drawable/format_bar_button_html_selector"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

0 comments on commit 68c6f4c

Please sign in to comment.