Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions res/layout/nux_dialog_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/white"
android:textSize="18sp"
android:textSize="16sp"
android:shadowColor="@color/black"
android:shadowDx="0"
android:shadowDy="1"
Expand Down Expand Up @@ -81,17 +81,17 @@
<org.wordpress.android.widgets.WPTextView
android:id="@+id/nux_dialog_learn_more_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="38dp"
android:textColor="@color/white"
android:text="@string/nux_tap_learn_more"
android:text="@string/cancel"
android:singleLine="true"
android:layout_alignParentStart="true"
android:gravity="center_vertical" />

<org.wordpress.android.widgets.WPTextView
android:id="@+id/nux_dialog_get_started_button"
android:layout_width="wrap_content"
android:layout_height="36dp"
android:layout_height="38dp"
style="@style/WordPress.NUXThirdButton"
android:text="@string/nux_tutorial_get_started_title"
android:singleLine="true"
Expand Down
2 changes: 1 addition & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<string name="sure_sign_out">Are you sure you want to sign out from WordPress.com?</string>
<string name="sign_out_confirm">Are you sure you want to sign out?</string>
<string name="please_sign_in">Please sign in again.</string>
<string name="account_two_step_auth_enabled">This account has two step authentication enabled. Please open WordPress.com in your browser, and generate an application-specific passwords to use with this app.\n(Log in to WordPress, and go to Settings->security).</string>
<string name="account_two_step_auth_enabled">This account has two step authentication enabled. Visit your security settings on WordPress.com and generate an application-specific password.</string>
<string name="visit_security_settings">Visit Security Settings</string>

<!-- form labels -->
Expand Down
32 changes: 28 additions & 4 deletions src/org/wordpress/android/ui/accounts/NUXDialogFragment.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.wordpress.android.ui.accounts;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
Expand All @@ -14,12 +16,14 @@
import org.wordpress.android.widgets.WPTextView;

public class NUXDialogFragment extends SherlockDialogFragment {

private static String ARG_TITLE = "title";
private static String ARG_DESCRIPTION = "message";
private static String ARG_FOOTER = "footer";
private static String ARG_IMAGE = "image";
private static String ARG_TWO_BUTTONS = "two-buttons";
private static String ARG_SECOND_BUTTON_LABEL = "second-btn-label";
private static String ARG_SECOND_BUTTON_ACTION = "second-btn-action";
private static String ARG_SECOND_BUTTON_PARAM = "second-btn-param";

private ImageView mImageView;
private WPTextView mTitleTextView;
Expand All @@ -29,24 +33,33 @@ public class NUXDialogFragment extends SherlockDialogFragment {
private WPTextView mFooterRightButton;
private RelativeLayout mFooterTwoButtons;

public static int ACTION_FINISH = 1;
public static int ACTION_OPEN_URL = 2;

public NUXDialogFragment() {
// Empty constructor required for DialogFragment
}

public static NUXDialogFragment newInstance(String title, String message, String footer,
int imageSource) {
return newInstance(title, message, footer, imageSource, false);
return newInstance(title, message, footer, imageSource, false, "", 0, "");
}

public static NUXDialogFragment newInstance(String title, String message, String footer,
int imageSource, boolean twoButtons) {
int imageSource, boolean twoButtons,
String secondButtonLabel, int secondButtonAction,
String secondButtonParam) {
NUXDialogFragment adf = new NUXDialogFragment();
Bundle bundle = new Bundle();
bundle.putString(ARG_TITLE, title);
bundle.putString(ARG_DESCRIPTION, message);
bundle.putString(ARG_FOOTER, footer);
bundle.putInt(ARG_IMAGE, imageSource);
bundle.putBoolean(ARG_TWO_BUTTONS, twoButtons);
bundle.putString(ARG_SECOND_BUTTON_LABEL, secondButtonLabel);
bundle.putInt(ARG_SECOND_BUTTON_ACTION, secondButtonAction);
bundle.putString(ARG_SECOND_BUTTON_PARAM, secondButtonParam);

adf.setArguments(bundle);
adf.setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme);
return adf;
Expand Down Expand Up @@ -75,6 +88,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
if (args.getBoolean(ARG_TWO_BUTTONS)) {
mFooterOneButton.setVisibility(View.GONE);
mFooterTwoButtons.setVisibility(View.VISIBLE);
mFooterRightButton.setText(args.getString(ARG_SECOND_BUTTON_LABEL));
}

View.OnClickListener clickListenerDismiss = new View.OnClickListener() {
Expand All @@ -84,10 +98,20 @@ public void onClick(View v) {
}
};

final int action = args.getInt(ARG_SECOND_BUTTON_ACTION, 0);
final String param = args.getString(ARG_SECOND_BUTTON_PARAM);

View.OnClickListener clickListenerFinish = new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
if (action == ACTION_FINISH) {
getActivity().finish();
}
if (action == ACTION_OPEN_URL) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(param));
startActivity(intent);
dismissAllowingStateLoss();
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/org/wordpress/android/ui/accounts/SetupBlog.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SetupBlog {
private String mHttpPassword = "";
private String mXmlrpcUrl;

private int mErrorMsgId = -1;
private int mErrorMsgId;
private boolean mIsCustomUrl;
private String mSelfHostedURL;

Expand Down
26 changes: 17 additions & 9 deletions src/org/wordpress/android/ui/accounts/WelcomeFragmentSignIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected void endProgress() {

private class SetupBlogTask extends AsyncTask<Void, Void, List<Object>> {
private SetupBlog mSetupBlog;
private String mErrorMsg;
private int mErrorMsgId;

@Override
protected void onPreExecute() {
Expand All @@ -231,9 +231,7 @@ protected void onPreExecute() {
@Override
protected List doInBackground(Void... args) {
List userBlogList = mSetupBlog.getBlogList();
if (mSetupBlog.getErrorMsgId() != -1) {
mErrorMsg = getString(mSetupBlog.getErrorMsgId());
}
mErrorMsgId = mSetupBlog.getErrorMsgId();
return userBlogList;
}

Expand Down Expand Up @@ -269,13 +267,23 @@ public void onClick(DialogInterface dialog, int whichButton) {
return;
}

if (usersBlogsList == null && mErrorMsg != null) {
if (usersBlogsList == null && mErrorMsgId != 0) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
NUXDialogFragment nuxAlert = NUXDialogFragment
.newInstance(getString(R.string.nux_cannot_log_in), mErrorMsg,
getString(R.string.nux_tap_continue), R.drawable.nux_icon_alert);
NUXDialogFragment nuxAlert;
if (mErrorMsgId == R.string.account_two_step_auth_enabled) {
nuxAlert = NUXDialogFragment.newInstance(getString(R.string.nux_cannot_log_in),
getString(mErrorMsgId), getString(R.string.nux_tap_continue),
R.drawable.nux_icon_alert, true,
getString(R.string.visit_security_settings),
NUXDialogFragment.ACTION_OPEN_URL,
"https://wordpress.com/settings/security/?ssl=forced");
} else {
nuxAlert = NUXDialogFragment.newInstance(getString(R.string.nux_cannot_log_in),
getString(mErrorMsgId), getString(R.string.nux_tap_continue),
R.drawable.nux_icon_alert);
}
nuxAlert.show(ft, "alert");
mErrorMsg = null;
mErrorMsgId = 0;
endProgress();
return;
}
Expand Down