From bf39d2825b5ff831ee515570e06bfd1afc95d13d Mon Sep 17 00:00:00 2001 From: Tyler Heck Date: Wed, 28 Nov 2018 18:30:24 -0600 Subject: [PATCH] Issue/post wordpress dialog (#601) * 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 --- .../simplenote/WordPressDialogFragment.java | 18 +- .../main/res/layout/dialog_wordpress_post.xml | 176 +++++++++--------- .../res/layout/list_item_single_choice.xml | 25 ++- Simplenote/src/main/res/values/dimens.xml | 1 + Simplenote/src/main/res/values/strings.xml | 3 +- 5 files changed, 118 insertions(+), 105 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/WordPressDialogFragment.java b/Simplenote/src/main/java/com/automattic/simplenote/WordPressDialogFragment.java index 29ef6b964..1b78104f2 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/WordPressDialogFragment.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/WordPressDialogFragment.java @@ -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; @@ -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 @@ -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(); } } }); @@ -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))); } @@ -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, - "%s
%s", + "%s
%s", site.getString(API_FIELD_NAME), site.getString(API_FIELD_URL) )); @@ -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) { @@ -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( diff --git a/Simplenote/src/main/res/layout/dialog_wordpress_post.xml b/Simplenote/src/main/res/layout/dialog_wordpress_post.xml index ed0efc418..07dd73f56 100644 --- a/Simplenote/src/main/res/layout/dialog_wordpress_post.xml +++ b/Simplenote/src/main/res/layout/dialog_wordpress_post.xml @@ -1,158 +1,160 @@ - + android:layout_width="match_parent" + android:orientation="vertical" > + android:visibility="gone" > + android:paddingTop="@dimen/padding_medium" > + + android:padding="@dimen/padding_large" > + tools:ignore="RtlSymmetry" > + + android:layout_weight="1" > + + + + 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" > + + + + android:textColor="?attr/noteTitleColor" + tools:ignore="RtlSymmetry" > + - + android:paddingLeft="@dimen/padding_extra_extra_large" + android:paddingRight="@dimen/padding_extra_extra_large" + android:paddingTop="@dimen/padding_large" > + android:textSize="16sp" > + - - - + + + - - - - + android:layout_width="wrap_content" + android:text="@string/copy" + android:theme="@style/FlatButton.Simplestyle" > + - + 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" > + android:textColor="?attr/noteTitleColor" > + - \ No newline at end of file + + diff --git a/Simplenote/src/main/res/layout/list_item_single_choice.xml b/Simplenote/src/main/res/layout/list_item_single_choice.xml index 1c51e2a14..3aa9cb129 100644 --- a/Simplenote/src/main/res/layout/list_item_single_choice.xml +++ b/Simplenote/src/main/res/layout/list_item_single_choice.xml @@ -1,14 +1,23 @@ - \ No newline at end of file + android:paddingRight="@dimen/padding_medium" + android:paddingStart="@dimen/padding_medium" + android:textColor="?attr/noteTitleColor" + android:textSize="18sp" + tools:text="Example Item" > + diff --git a/Simplenote/src/main/res/values/dimens.xml b/Simplenote/src/main/res/values/dimens.xml index ad162694e..4bd8e309b 100644 --- a/Simplenote/src/main/res/values/dimens.xml +++ b/Simplenote/src/main/res/values/dimens.xml @@ -9,6 +9,7 @@ 12dp 16dp 20dp + 24dp 48dp diff --git a/Simplenote/src/main/res/values/strings.xml b/Simplenote/src/main/res/values/strings.xml index 2d2882bd6..c8814d9b4 100644 --- a/Simplenote/src/main/res/values/strings.xml +++ b/Simplenote/src/main/res/values/strings.xml @@ -215,8 +215,7 @@ Post Set status to draft Uploading post - Copy URL - Successfully posted to + Successfully posted note to: %1$s Done To post a note directly to a WordPress site, connect your WordPress.com account. Connect