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
33 changes: 4 additions & 29 deletions res/layout/activity_welcome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,10 @@
android:orientation="vertical"
android:baselineAligned="true">

<FrameLayout
<fragment
android:name="org.wordpress.android.ui.accounts.WelcomeFragmentSignIn"
android:id="@+id/sign_in_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >

<org.wordpress.android.util.WPViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<org.wordpress.android.util.LinePageIndicator
android:id="@+id/pageIndicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:layout_gravity="bottom"
/>

<org.wordpress.android.widgets.WPTextView
android:id="@+id/nux_sign_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"
android:text="@string/dont_have_account"
android:visibility="gone"
android:background="@drawable/selectable_background_wordpress"
/>

</FrameLayout>
android:layout_height="match_parent" />

</LinearLayout>
1 change: 0 additions & 1 deletion src/org/wordpress/android/ui/WPActionBarActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ public void setupCurrentBlog() {
Intent intent = new Intent(this, WelcomeActivity.class);
intent.putExtra("request", WelcomeActivity.SIGN_IN_REQUEST);
startActivityForResult(intent, ADD_ACCOUNT_REQUEST);
return;
}
}

Expand Down
95 changes: 15 additions & 80 deletions src/org/wordpress/android/ui/accounts/WelcomeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,108 +2,44 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Window;

import org.wordpress.android.R;
import org.wordpress.android.util.WPViewPager;


// TODO: this will probably be merged with New Account Activity (maybe add a tab bar)
public class WelcomeActivity extends SherlockFragmentActivity {
/**
* The number of pages (wizard steps)
*/
private static final int NUM_PAGES = 1; // TODO: this will probably be merged with New
// Account Activity
public static final int SIGN_IN_REQUEST = 1;
public static final int ADD_SELF_HOSTED_BLOG = 2;
public static final int CREATE_ACCOUNT_REQUEST = 3;

public static String START_FRAGMENT_KEY = "start-fragment";

/**
* The pager widget, which handles animation and allows swiping horizontally to access previous
* and next wizard steps.
*/
private WPViewPager mPager;

/**
* The pager adapter, which provides the pages to the view pager widget.
*/
private NewAccountPagerAdapter mPagerAdapter;
private int mActionMode;
private WelcomeFragmentSignIn mWelcomeFragmentSignIn;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_welcome);

// Instantiate a ViewPager and a PagerAdapter.
mPager = (WPViewPager) findViewById(R.id.pager);
mPager.setPagingEnabled(false);
mPagerAdapter = new NewAccountPagerAdapter(super.getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);

Bundle extras = getIntent().getExtras();
mActionMode = SIGN_IN_REQUEST;
if (extras != null) {
mActionMode = extras.getInt(START_FRAGMENT_KEY, -1);
}
}

public void showNextItem() {
mPager.setCurrentItem(mPager.getCurrentItem() + 1);
}

public void showPrevItem() {
if (mPager.getCurrentItem() == 0)
return;
mPager.setCurrentItem(mPager.getCurrentItem() - 1);
FragmentManager fragmentManager = getSupportFragmentManager();
mWelcomeFragmentSignIn = (WelcomeFragmentSignIn) fragmentManager.
findFragmentById(R.id.sign_in_fragment);
actionMode(getIntent().getExtras());
}

@Override
public void onBackPressed() {
if (mPager.getCurrentItem() == 0)
super.onBackPressed();
if (mPager.getPreviousPage() < mPager.getCurrentItem())
mPager.setCurrentItem(mPager.getPreviousPage());
else
showPrevItem();
}

private class NewAccountPagerAdapter extends FragmentStatePagerAdapter {
public NewAccountPagerAdapter(FragmentManager fm) {
super(fm);
}

@Override
public Fragment getItem(int position) {
NewAccountAbstractPageFragment currentPage = null;
Bundle args = new Bundle();

switch (position) {
default:
mWelcomeFragmentSignIn = new WelcomeFragmentSignIn();
if (mActionMode == ADD_SELF_HOSTED_BLOG) {
mWelcomeFragmentSignIn.setForceSelfHostedMode(true);
}
currentPage = mWelcomeFragmentSignIn;
break;
}

currentPage.setArguments(args);
return currentPage;
private void actionMode(Bundle extras) {
int actionMode = SIGN_IN_REQUEST;
if (extras != null) {
actionMode = extras.getInt(START_FRAGMENT_KEY, -1);
}

@Override
public int getCount() {
return NUM_PAGES;
switch (actionMode) {
case ADD_SELF_HOSTED_BLOG:
mWelcomeFragmentSignIn.forceSelfHostedMode();
break;
default:
break;
}
}

Expand All @@ -113,7 +49,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK && data != null) {
String username = data.getStringExtra("username");
if (username != null) {
mPager.setCurrentItem(1);
mWelcomeFragmentSignIn.signInDotComUser();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public class WelcomeFragmentSignIn extends NewAccountAbstractPageFragment implem
private String mHttpPassword = "";
private EmailChecker mEmailChecker;
private boolean mEmailAutoCorrected;
private boolean mForceSelfHosted;

public WelcomeFragmentSignIn() {
mEmailChecker = new EmailChecker();
Expand Down Expand Up @@ -100,21 +99,14 @@ public void onFocusChange(View v, boolean hasFocus) {
}
}
});
if (mForceSelfHosted) {
forceSelfHostedMode();
}
return rootView;
}

public void setForceSelfHostedMode(boolean force) {
mForceSelfHosted = force;
}

/**
* Hide toggle button "add self hosted / sign in with WordPress.com" and show self hosted URL
* edit box
*/
private void forceSelfHostedMode() {
public void forceSelfHostedMode() {
mUrlButtonLayout.setVisibility(View.VISIBLE);
mAddSelfHostedButton.setVisibility(View.GONE);
mCreateAccountButton.setVisibility(View.GONE);
Expand Down