Skip to content

Commit

Permalink
Issue/post wordpress dialog (#601)
Browse files Browse the repository at this point in the history
* Update connect section in post dialog layout

* Update single choice list item layout with drawable and view padding

* Update attributes of fields section in post dialog layout

* Update site list URL HTML in post dialog to mimic note list row style

* Update posting section in post dialog layout to mimic progress dialog

* Update post button visibility in post dialog to mimic progress dialog

* Update success message in post dialog to use a single text view

* Update success section in post dialog layout

* Add confirmation message when post dialog URL copied to clipboard

* Update hard-coded values to references in success section of post wordpress dialog

* Update confirmation message when post dialog URL copied to clipboard

* Update copy button in success section of post wordpress dialog
  • Loading branch information
theck13 authored and roundhill committed Nov 29, 2018
1 parent b9a4266 commit bf39d28
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ public class WordPressDialogFragment extends AppCompatDialogFragment {
private View mConnectSection, mPostingSection, mFieldsSection, mSuccessSection;
private ListView mListView;
private CheckBox mDraftCheckbox;
private TextView mPostUrlTextView;
private TextView mPostSuccessTextView;
private Button mPostButton, mCancelButton;
private String mPostUrl;

private JSONArray mSitesArray = new JSONArray();
private Note mNote;
Expand All @@ -91,7 +92,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {

Button copyUrlButton = view.findViewById(R.id.wp_dialog_copy_url);
Button shareUrlButton = view.findViewById(R.id.wp_dialog_share);
mPostUrlTextView = view.findViewById(R.id.wp_dialog_success_url);
mPostSuccessTextView = view.findViewById(R.id.wp_dialog_success_summary);

copyUrlButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -102,8 +103,9 @@ public void onClick(View view) {

ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
if (clipboard != null) {
ClipData clip = ClipData.newPlainText("Simplenote", mPostUrlTextView.getText());
ClipData clip = ClipData.newPlainText("Simplenote", mPostUrl);
clipboard.setPrimaryClip(clip);
Toast.makeText(requireContext(), R.string.link_copied, Toast.LENGTH_SHORT).show();
}
}
});
Expand All @@ -117,7 +119,7 @@ public void onClick(View view) {

Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_TEXT, mPostUrlTextView.getText());
share.putExtra(Intent.EXTRA_TEXT, mPostUrl);

startActivity(Intent.createChooser(share, getString(R.string.wordpress_post_link)));
}
Expand Down Expand Up @@ -221,7 +223,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
JSONObject site = mSitesArray.getJSONObject(position);
Spanned rowText = Html.fromHtml(String.format(
Locale.ENGLISH,
"<big>%s</big><br /><em>%s</em>",
"%s<br/><small><span style=\"color:#899199\">%s</span></small>",
site.getString(API_FIELD_NAME),
site.getString(API_FIELD_URL)
));
Expand Down Expand Up @@ -280,9 +282,8 @@ private void setDialogStatus(DialogStatus status) {
mPostingSection.setVisibility(status == DialogStatus.POSTING ? View.VISIBLE : View.GONE);
mSuccessSection.setVisibility(status == DialogStatus.SUCCESS ? View.VISIBLE : View.GONE);
mCancelButton.setVisibility(status == DialogStatus.FIELDS || status == DialogStatus.CONNECT ? View.VISIBLE : View.GONE);
mPostButton.setVisibility(status == DialogStatus.POSTING ? View.GONE : View.VISIBLE);

// Set state and text of the dialog positive button
mPostButton.setEnabled(!(status == DialogStatus.POSTING));
if (status == DialogStatus.SUCCESS) {
mPostButton.setText(R.string.done);
} else if (status == DialogStatus.CONNECT) {
Expand Down Expand Up @@ -430,7 +431,8 @@ public void run() {
String responseString = response.body().string();
JSONObject postResult = new JSONObject(responseString);

mPostUrlTextView.setText(postResult.getString(API_FIELD_URL));
mPostUrl = postResult.getString(API_FIELD_URL);
mPostSuccessTextView.setText(getString(R.string.success, mPostUrl));
setDialogStatus(DialogStatus.SUCCESS);

AnalyticsTracker.track(
Expand Down
176 changes: 89 additions & 87 deletions Simplenote/src/main/res/layout/dialog_wordpress_post.xml
Original file line number Diff line number Diff line change
@@ -1,158 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_width="match_parent"
android:orientation="vertical" >

<LinearLayout
android:id="@+id/wp_dialog_section_fields"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical"
android:visibility="gone">
android:visibility="gone" >

<ListView
android:id="@+id/wp_dialog_list_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:choiceMode="singleChoice"
android:clipToPadding="false"
android:divider="@null"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:listSelector="@drawable/selectable_background_simplestyle"
android:paddingLeft="@dimen/padding_extra_small"
android:paddingRight="@dimen/padding_extra_small"
android:listSelector="@drawable/selectable_background_simplestyle"
android:paddingTop="@dimen/padding_medium" />
android:paddingTop="@dimen/padding_medium" >
</ListView>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="horizontal"
android:padding="@dimen/padding_large">
android:padding="@dimen/padding_large" >

<CheckBox
android:id="@+id/wp_dialog_draft_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingLeft="@dimen/padding_medium"
android:paddingStart="@dimen/padding_medium"
android:text="@string/wordpress_post_draft"
android:textColor="?attr/noteTitleColor"
android:textSize="16sp"
android:textColor="?attr/noteTitleColor" />
tools:ignore="RtlSymmetry" >
</CheckBox>

<Space
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
android:layout_weight="1" >
</Space>

</LinearLayout>

</LinearLayout>

<LinearLayout
android:id="@+id/wp_dialog_section_posting"
android:layout_width="match_parent"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="@dimen/padding_large"
android:layout_width="match_parent"
android:orientation="horizontal"
android:paddingBottom="@dimen/padding_large"
android:orientation="vertical"
android:visibility="gone">
android:paddingEnd="@dimen/padding_extra_extra_large"
android:paddingLeft="@dimen/padding_extra_extra_large"
android:paddingRight="@dimen/padding_extra_extra_large"
android:paddingStart="@dimen/padding_extra_extra_large"
android:paddingTop="@dimen/padding_large"
android:visibility="gone" >

<ProgressBar
android:indeterminate="true"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/padding_extra_extra_large"
android:layout_marginRight="@dimen/padding_extra_extra_large"
android:layout_width="wrap_content" >
</ProgressBar>

<TextView
android:layout_width="match_parent"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/padding_medium"
android:layout_marginBottom="@dimen/padding_medium"
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:maxLines="1"
android:text="@string/uploading_post"
android:textColor="?attr/noteTitleColor" />
android:textColor="?attr/noteTitleColor"
tools:ignore="RtlSymmetry" >
</TextView>

<ProgressBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding_large"
android:gravity="center_horizontal"
android:indeterminate="true" />
</LinearLayout>

<RelativeLayout
android:id="@+id/wp_dialog_section_success"
android:layout_width="match_parent"
android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="@dimen/padding_large"
android:layout_width="match_parent"
android:paddingBottom="@dimen/padding_large"
android:layout_gravity="center_horizontal">
android:paddingLeft="@dimen/padding_extra_extra_large"
android:paddingRight="@dimen/padding_extra_extra_large"
android:paddingTop="@dimen/padding_large" >

<TextView
android:id="@+id/wp_dialog_success_summary"
android:layout_width="match_parent"
android:autoLink="web"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding_medium"
android:gravity="center_horizontal"
android:layout_width="match_parent"
android:text="@string/success"
android:textColor="?attr/noteTitleColor"
android:textSize="16sp" />
android:textSize="16sp" >
</TextView>

<TextView
android:id="@+id/wp_dialog_success_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
<android.support.v7.widget.AppCompatButton
android:id="@+id/wp_dialog_share"
android:drawablePadding="@dimen/padding_extra_small"
android:layout_below="@id/wp_dialog_success_summary"
android:layout_centerHorizontal="true"
android:layout_marginBottom="@dimen/padding_medium"
android:autoLink="web"
android:textSize="16sp" />

<LinearLayout
android:id="@+id/wp_dialog_share_buttons"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/share"
android:theme="@style/FlatButton.Simplestyle" >
</android.support.v7.widget.AppCompatButton>

<android.support.v7.widget.AppCompatButton
android:id="@+id/wp_dialog_copy_url"
android:drawablePadding="@dimen/padding_extra_small"
android:layout_below="@id/wp_dialog_share"
android:layout_height="wrap_content"
android:layout_below="@id/wp_dialog_success_url"
android:layout_centerHorizontal="true"
android:orientation="horizontal">

<android.support.v7.widget.AppCompatButton
android:id="@+id/wp_dialog_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="@dimen/padding_extra_small"
android:layout_marginRight="@dimen/padding_extra_small"
android:drawablePadding="@dimen/padding_extra_small"
android:text="@string/share"
android:theme="@style/FlatButton.Simplestyle" />

<android.support.v7.widget.AppCompatButton
android:id="@+id/wp_dialog_copy_url"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:drawablePadding="@dimen/padding_extra_small"
android:text="@string/copy_url"
android:theme="@style/FlatButton.Simplestyle" />
android:layout_width="wrap_content"
android:text="@string/copy"
android:theme="@style/FlatButton.Simplestyle" >
</android.support.v7.widget.AppCompatButton>

</LinearLayout>
</RelativeLayout>

<RelativeLayout
android:id="@+id/wp_dialog_section_connect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="24dp"
android:paddingRight="24dp"
android:paddingTop="@dimen/padding_large"
android:orientation="vertical">
android:layout_width="match_parent"
android:paddingBottom="@dimen/padding_medium"
android:paddingEnd="@dimen/padding_extra_extra_large"
android:paddingLeft="@dimen/padding_extra_extra_large"
android:paddingRight="@dimen/padding_extra_extra_large"
android:paddingStart="@dimen/padding_extra_extra_large"
android:paddingTop="@dimen/padding_large" >

<TextView
android:id="@+id/wp_dialog_connect_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/padding_medium"
android:gravity="start"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/wordpress_connect_summary"
android:textColor="?attr/noteTitleColor" />
android:textColor="?attr/noteTitleColor" >
</TextView>

</RelativeLayout>
</LinearLayout>

</LinearLayout>
25 changes: 17 additions & 8 deletions Simplenote/src/main/res/layout/list_item_single_choice.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.AppCompatCheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"

<android.support.v7.widget.AppCompatCheckedTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:checkMark="@null"
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
android:drawableLeft="?android:attr/listChoiceIndicatorSingle"
android:paddingStart="@dimen/padding_medium"
android:drawablePadding="@dimen/padding_medium"
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:lineSpacingExtra="4dp"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingEnd="@dimen/padding_medium"
android:paddingLeft="@dimen/padding_medium"
android:paddingRight="@dimen/padding_medium" />
android:paddingRight="@dimen/padding_medium"
android:paddingStart="@dimen/padding_medium"
android:textColor="?attr/noteTitleColor"
android:textSize="18sp"
tools:text="Example Item" >
</android.support.v7.widget.AppCompatCheckedTextView>
1 change: 1 addition & 0 deletions Simplenote/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<dimen name="padding_medium">12dp</dimen>
<dimen name="padding_large">16dp</dimen>
<dimen name="padding_extra_large">20dp</dimen>
<dimen name="padding_extra_extra_large">24dp</dimen>

<!-- http://www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-keylines-spacing -->
<dimen name="nav_row_height">48dp</dimen>
Expand Down
3 changes: 1 addition & 2 deletions Simplenote/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,7 @@
<string name="send_post">Post</string>
<string name="wordpress_post_draft">Set status to draft</string>
<string name="uploading_post">Uploading post</string>
<string name="copy_url">Copy URL</string>
<string name="success">Successfully posted to</string>
<string name="success">Successfully posted note to: %1$s</string>
<string name="done">Done</string>
<string name="wordpress_connect_summary">To post a note directly to a WordPress site, connect your WordPress.com account.</string>
<string name="connect_with_wordpress">Connect</string>
Expand Down

0 comments on commit bf39d28

Please sign in to comment.