Skip to content

Commit

Permalink
Merge pull request #140 from wordpress-mobile/issue/18-format-bar-tablet
Browse files Browse the repository at this point in the history
Issue #18: Format bar (tablet)
  • Loading branch information
bummytime committed Apr 30, 2015
2 parents 8a1bf41 + 2fe6c3f commit 40e798b
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class EditorFragment extends EditorFragmentAbstract implements View.OnCli
private static final String TAG_FORMAT_BAR_BUTTON_UL = "unorderedList";
private static final String TAG_FORMAT_BAR_BUTTON_OL = "orderedList";
private static final String TAG_FORMAT_BAR_BUTTON_LINK = "link";
private static final String TAG_FORMAT_BAR_BUTTON_STRIKETHROUGH = "strikeThrough";

private static final float TOOLBAR_ALPHA_ENABLED = 1;
private static final float TOOLBAR_ALPHA_DISABLED = 0.5f;
Expand Down Expand Up @@ -96,6 +97,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
ToggleButton linkButton = (ToggleButton) view.findViewById(R.id.format_bar_button_link);
mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_LINK, linkButton);

// Tablet-only
ToggleButton strikethroughButton = (ToggleButton) view.findViewById(R.id.format_bar_button_strikethrough);
if (strikethroughButton != null) {
mTagToggleButtonMap.put(TAG_FORMAT_BAR_BUTTON_STRIKETHROUGH, strikethroughButton);
}

ToggleButton htmlButton = (ToggleButton) view.findViewById(R.id.format_bar_button_html);
htmlButton.setOnClickListener(this);

Expand Down Expand Up @@ -128,6 +135,8 @@ public void onClick(View v) {
mWebView.execJavaScriptFromString("ZSSEditor.setBold();");
} else if (id == R.id.format_bar_button_italic) {
mWebView.execJavaScriptFromString("ZSSEditor.setItalic();");
} else if (id == R.id.format_bar_button_strikethrough) {
mWebView.execJavaScriptFromString("ZSSEditor.setStrikeThrough();");
} else if (id == R.id.format_bar_button_quote) {
mWebView.execJavaScriptFromString("ZSSEditor.setBlockquote();");
} else if (id == R.id.format_bar_button_ul) {
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:src="@drawable/format_bar_button_strikethrough_highlighted"
android:gravity="center"/>
</item>
<item android:top="@dimen/format_bar_button_highlighted_underline_top">
<shape android:shape="line">
<stroke
android:width="@dimen/format_bar_button_highlighted_underline_width"
android:color="@color/format_bar_button_highlighted_color"/>
</shape>
</item>
</layer-list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/format_bar_button_strikethrough_selected_state"/>
<item android:state_pressed="true" android:drawable="@drawable/format_bar_button_strikethrough_selected_state"/>
<item>
<bitmap
android:src="@drawable/format_bar_button_strikethrough"
android:gravity="center"/>
</item>
</selector>
129 changes: 129 additions & 0 deletions WordPressEditor/src/main/res/layout-sw600dp/fragment_editor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.wordpress.android.editor.EditorFragment">

<include
layout="@layout/editor_webview"
android:id="@+id/webview" />

<LinearLayout
android:id="@+id/format_bar"
android:layout_width="fill_parent"
android:layout_height="@dimen/format_bar_height"
android:layout_gravity="bottom"
android:background="@android:color/white"
android:orientation="vertical">

<View
android:id="@+id/format_bar_horizontal_divider"
android:layout_width="fill_parent"
android:layout_height="@dimen/format_bar_horizontal_divider_height"
style="@style/Divider"/>

<LinearLayout
android:id="@+id/format_bar_buttons"
android:layout_width="fill_parent"
android:layout_height="@dimen/format_bar_height"
android:layout_gravity="bottom"
android:gravity="center"
android:orientation="horizontal"
tools:ignore="RtlHardcoded">

<LinearLayout
style="@style/FormatBarTabletGroup"
android:layout_width="wrap_content"
android:layout_height="fill_parent">

<ToggleButton
android:id="@+id/format_bar_button_media"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_media_selector"/>
</LinearLayout>

<LinearLayout
style="@style/FormatBarTabletGroup"
android:layout_width="wrap_content"
android:layout_height="fill_parent">

<ToggleButton
android:id="@+id/format_bar_button_bold"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_bold_selector"/>

<ToggleButton
android:id="@+id/format_bar_button_italic"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_italic_selector"/>

<ToggleButton
android:id="@+id/format_bar_button_strikethrough"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_strikethrough_selector"/>
</LinearLayout>

<LinearLayout
style="@style/FormatBarTabletGroup"
android:layout_width="wrap_content"
android:layout_height="fill_parent">

<ToggleButton
android:id="@+id/format_bar_button_link"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_link_selector"/>
</LinearLayout>

<LinearLayout
style="@style/FormatBarTabletGroup"
android:layout_width="wrap_content"
android:layout_height="fill_parent">

<ToggleButton
android:id="@+id/format_bar_button_ul"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_ul_selector"/>

<ToggleButton
android:id="@+id/format_bar_button_ol"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_ol_selector"/>

<ToggleButton
android:id="@+id/format_bar_button_quote"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_quote_selector"/>
</LinearLayout>

<LinearLayout
style="@style/FormatBarTabletGroup"
android:layout_width="wrap_content"
android:layout_height="fill_parent">

<ToggleButton
android:id="@+id/format_bar_button_html"
style="@style/FormatBarButtonTablet"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="@drawable/format_bar_button_html_selector"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

</FrameLayout>
4 changes: 1 addition & 3 deletions WordPressEditor/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
<dimen name="format_bar_button_right_margin">4dp</dimen>
<dimen name="format_bar_html_button_left_margin">3dp</dimen>

<dimen name="format_bar_left_margin_tablet">5dp</dimen>
<dimen name="format_bar_right_margin_tablet">9dp</dimen>
<dimen name="format_bar_html_button_left_margin_tablet">9dp</dimen>
<dimen name="format_bar_button_margin_tablet">2dp</dimen>

<dimen name="format_bar_horizontal_divider_height">1dp</dimen>
<dimen name="format_bar_vertical_divider_width">0.6dp</dimen>
Expand Down
10 changes: 10 additions & 0 deletions WordPressEditor/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<item name="android:textOff">""</item>
</style>

<style name="FormatBarButtonTablet" parent="FormatBarButton">
<item name="android:layout_marginRight">@dimen/format_bar_button_margin_tablet</item>
<item name="android:layout_marginLeft">@dimen/format_bar_button_margin_tablet</item>
</style>

<style name="FormatBarScrollViewButton" parent="FormatBarButton">
<item name="android:layout_marginRight">@dimen/format_bar_button_right_margin</item>
</style>
Expand All @@ -26,4 +31,9 @@
<item name="android:background">@color/wp_gray</item>
<item name="android:alpha">0.5</item>
</style>

<style name="FormatBarTabletGroup">
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginRight">20dp</item>
</style>
</resources>

0 comments on commit 40e798b

Please sign in to comment.