Skip to content

Commit f144a88

Browse files
committed
Linked up format bar buttons to ZSSEditor methods
- Isolated the HTML button so it's not disabled like the rest when the title is the active field
1 parent 570ae57 commit f144a88

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli
5252
private Activity mActivity;
5353
private EditorWebView mWebView;
5454

55+
private ToggleButton mHtmlButton;
56+
5557
private final Map<String, ToggleButton> mTagToggleButtonMap = new HashMap<>();
5658

5759
public static EditorFragment newInstance(String title, String content) {
@@ -103,8 +105,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
103105
ToggleButton linkButton = (ToggleButton) view.findViewById(R.id.format_bar_button_link);
104106
mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_LINK, linkButton);
105107

106-
ToggleButton htmlButton = (ToggleButton) view.findViewById(R.id.format_bar_button_html);
107-
mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_HTML, htmlButton);
108+
mHtmlButton = (ToggleButton) view.findViewById(R.id.format_bar_button_html);
109+
mHtmlButton.setOnClickListener(this);
108110

109111
for (ToggleButton button : mTagToggleButtonMap.values()) {
110112
button.setOnClickListener(this);
@@ -154,8 +156,25 @@ public boolean onJsAlert(WebView view, String url, String message, JsResult resu
154156
@Override
155157
public void onClick(View v) {
156158
int id = v.getId();
157-
if (id == R.id.bold) {
159+
if (id == R.id.format_bar_button_bold) {
158160
mWebView.execJavaScriptFromString("ZSSEditor.setBold();");
161+
} else if (id == R.id.format_bar_button_italic) {
162+
mWebView.execJavaScriptFromString("ZSSEditor.setItalic();");
163+
} else if (id == R.id.format_bar_button_quote) {
164+
mWebView.execJavaScriptFromString("ZSSEditor.setBlockquote();");
165+
} else if (id == R.id.format_bar_button_ul) {
166+
mWebView.execJavaScriptFromString("ZSSEditor.setUnorderedList();");
167+
} else if (id == R.id.format_bar_button_ol) {
168+
mWebView.execJavaScriptFromString("ZSSEditor.setOrderedList();");
169+
} else if (id == R.id.format_bar_button_media) {
170+
// TODO: Handle inserting media
171+
((ToggleButton) v).setChecked(false);
172+
} else if (id == R.id.format_bar_button_link) {
173+
// TODO: Handle inserting a link
174+
((ToggleButton) v).setChecked(false);
175+
} else if (id == R.id.format_bar_button_html) {
176+
// TODO: Handle HTML mode toggling
177+
((ToggleButton) v).setChecked(false);
159178
}
160179
}
161180

0 commit comments

Comments
 (0)