Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125442
b: refs/heads/feature/wpstores-integration
c: 14a199b
h: refs/heads/develop
  • Loading branch information
aforcier committed Mar 31, 2016
1 parent dfb5282 commit eff160c
Show file tree
Hide file tree
Showing 59 changed files with 713 additions and 217 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ refs/heads/poc/gravatar-upload: 535722dcde11506c8e1d3d449027625b4471a796
refs/tags/5.1: 77e7d1258813dadd88b8ad10dadd7838261bd81e
refs/tags/alpha-2: c88114d38da45ee56016e1365fc4ea7c66055bde
refs/tags/alpha-3: d70e6367151f7da2e10fd7fb46e98748b1031935
refs/heads/feature/wpstores-integration: 6ba110d926a53ec4770d237faa33054adb8c6f4e
refs/heads/feature/wpstores-integration: 14a199bf09de84fcd1b356f218715636bed68506
refs/heads/issue/plans-upgrade-plans-endpoint-1-1: bdb570c1e071ad5ee8ebbbef41208ee05964370f
refs/tags/5.1.1: 9fb73b0316da9fbec51842ab87c05731a859159a
refs/tags/alpha-4: 32f92296c71999c798a6478eb2feded45c958c55
Expand Down
3 changes: 2 additions & 1 deletion branches/feature/wpstores-integration/WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta7'
classpath 'com.android.tools.build:gradle:2.0.0-rc1'
classpath 'io.fabric.tools:gradle:1.+'
}
}
Expand Down Expand Up @@ -86,6 +86,7 @@ dependencies {
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:percent:23.1.1'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile 'com.helpshift:android-helpshift-aar:4.4.0'
Expand Down
3 changes: 3 additions & 0 deletions branches/feature/wpstores-integration/WordPress/lint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@

<issue id="HardcodedText" severity="error" />
<issue id="InconsistentArrays" severity="warning" />

<issue id="IconDuplicates" severity="error" />
<issue id="IconDipSize" severity="error" />
</lint>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.json.JSONObject;
import org.wordpress.android.TestUtils;
import org.wordpress.android.WordPress;
import org.wordpress.android.ui.accounts.helpers.FetchBlogListWPOrg;
import org.xmlrpc.android.LoggedInputStream;
import org.xmlrpc.android.XMLRPCUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.wordpress.android.util.JSONUtils;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

// Maps to notification settings returned from the /me/notifications/settings endpoint on wp.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.wordpress.android.models.AccountHelper;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.util.UrlUtils;
import org.wordpress.android.util.WPUrlUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class MediaPickerActivity extends AppCompatActivity

private static final String CAPTURE_PATH_KEY = "capture-path";

private static final long TAB_ANIMATION_DURATION_MS = 250l;
private static final long TAB_ANIMATION_DURATION_MS = 250L;

private MediaPickerAdapter mMediaPickerAdapter;
private ArrayList<MediaSource>[] mMediaSources;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,38 @@
import java.util.List;

/**
* post-purchase "on-boarding" experience
* post-purchase "on-boarding" experience after user purchases premium or business plan
*/
public class PlanPostPurchaseActivity extends AppCompatActivity {

static final int PAGE_NUMBER_INTRO = 0;
static final int PAGE_NUMBER_CUSTOMIZE = 1;
static final int PAGE_NUMBER_VIDEO = 2;
static final int PAGE_NUMBER_THEMES = 3; // business only

static final String ARG_IS_BUSINESS_PLAN = "is_business_plan";

private ViewPager mViewPager;
private PageAdapter mPageAdapter;
private TextView mTxtSkip;
private TextView mTxtNext;
private ViewGroup mIndicatorContainerView;

private int mPrevPageNumber = 0;
private static final int NUM_PAGES = 4;
private boolean mIsBusinessPlan;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.plan_post_purchase_activity);

if (savedInstanceState != null) {
mIsBusinessPlan = savedInstanceState.getBoolean(ARG_IS_BUSINESS_PLAN, false);
} else {
mIsBusinessPlan = getIntent().getBooleanExtra(ARG_IS_BUSINESS_PLAN, false);
}

mTxtSkip = (TextView) findViewById(R.id.text_skip);
mTxtNext = (TextView) findViewById(R.id.text_next);
mIndicatorContainerView = (ViewGroup) findViewById(R.id.layout_indicator_container);
Expand Down Expand Up @@ -78,16 +91,31 @@ public void onClick(View v) {
}
});

for (int i = 0; i < NUM_PAGES; i++) {
int numPages = getNumPages();
for (int i = 0; i < numPages; i++) {
getIndicator(i).setOnClickListener(mIndicatorClickListener);
}
getIndicator(PAGE_NUMBER_THEMES).setVisibility(numPages > 3 ? View.VISIBLE : View.GONE);
}

@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(ARG_IS_BUSINESS_PLAN, mIsBusinessPlan);
}

/*
* last pages is themes, which should only appear when user has purchased business plan
*/
private int getNumPages() {
return mIsBusinessPlan ? 4 : 3;
}

private PageAdapter getPageAdapter() {
if (mPageAdapter == null) {
List<Fragment> fragments = new ArrayList<>();
for (int i = 0; i < NUM_PAGES; i++) {
fragments.add(PlanPostPurchaseFragment.newInstance());
for (int i = 0; i < getNumPages(); i++) {
fragments.add(PlanPostPurchaseFragment.newInstance(i));
}

FragmentManager fm = getFragmentManager();
Expand All @@ -101,7 +129,7 @@ private int getCurrentPage() {
}

private boolean isLastPage() {
return getCurrentPage() == NUM_PAGES - 1;
return getCurrentPage() == getNumPages() - 1;
}

private void gotoNextPage() {
Expand Down Expand Up @@ -134,16 +162,16 @@ private ImageView getIndicator(int pageNumber) {
@IdRes int resId;
switch (pageNumber) {
case 0:
resId = R.id.image_indicator_0;
resId = R.id.image_indicator_1;
break;
case 1:
resId = R.id.image_indicator_1;
resId = R.id.image_indicator_2;
break;
case 2:
resId = R.id.image_indicator_2;
resId = R.id.image_indicator_3;
break;
case 3:
resId = R.id.image_indicator_3;
resId = R.id.image_indicator_4;
break;
default:
throw new IllegalArgumentException("Invalid indicator page number");
Expand Down Expand Up @@ -182,13 +210,13 @@ public void onAnimationRepeat(Animator animation) {
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.image_indicator_0) {
if (id == R.id.image_indicator_1) {
gotoPage(0);
} else if (id == R.id.image_indicator_1) {
gotoPage(1);
} else if (id == R.id.image_indicator_2) {
gotoPage(2);
gotoPage(1);
} else if (id == R.id.image_indicator_3) {
gotoPage(2);
} else if (id == R.id.image_indicator_4) {
gotoPage(3);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import android.app.Fragment;
import android.os.Bundle;
import android.support.percent.PercentLayoutHelper;
import android.support.percent.PercentRelativeLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -10,15 +12,46 @@
import android.widget.TextView;

import org.wordpress.android.R;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.WordPress;
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.themes.ThemeWebActivity;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.DisplayUtils;

/**
* single page within the post-purchase activity's ViewPager
*/
public class PlanPostPurchaseFragment extends Fragment {

static PlanPostPurchaseFragment newInstance() {
return new PlanPostPurchaseFragment();
private static final String ARG_PAGE_NUMBER = "page_number";
private int mPageNumber;

static PlanPostPurchaseFragment newInstance(int pageNumber) {
PlanPostPurchaseFragment fragment = new PlanPostPurchaseFragment();
Bundle args = new Bundle();
args.putInt(ARG_PAGE_NUMBER, pageNumber);
fragment.setArguments(args);
return fragment;
}

@Override
public void setArguments(Bundle args) {
super.setArguments(args);
mPageNumber = args.getInt(ARG_PAGE_NUMBER);
}

@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putInt(ARG_PAGE_NUMBER, mPageNumber);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
mPageNumber = savedInstanceState.getInt(ARG_PAGE_NUMBER);
}
}

@Override
Expand All @@ -30,18 +63,83 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
TextView txtDescription = (TextView) rootView.findViewById(R.id.text_description);
Button button = (Button) rootView.findViewById(R.id.button);

// TODO: these are placeholders until actual copy exists
image.setImageResource(R.drawable.penandink);
txtTitle.setText("This is the title");
txtDescription.setText("This is the description. It is a nice description and deserves to be respected.");
button.setText("Don\'t Press This");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ToastUtils.showToast(v.getContext(), "You never listen");
// reduce size of image in landscape
if (DisplayUtils.isLandscape(getActivity())) {
PercentRelativeLayout.LayoutParams params = (PercentRelativeLayout.LayoutParams) image.getLayoutParams();
PercentLayoutHelper.PercentLayoutInfo info = params.getPercentLayoutInfo();
if (info != null) {
info.heightPercent = 0.20f;
}
});
}

int titleResId;
int textResId;
int buttonResId;
int imageResId;
switch (mPageNumber) {
case PlanPostPurchaseActivity.PAGE_NUMBER_INTRO:
titleResId = R.string.plans_post_purchase_title_intro;
textResId = R.string.plans_post_purchase_text_intro;
buttonResId = 0;
imageResId = R.drawable.plans_business_active;
break;
case PlanPostPurchaseActivity.PAGE_NUMBER_CUSTOMIZE:
titleResId = R.string.plans_post_purchase_title_customize;
textResId = R.string.plans_post_purchase_text_customize;
buttonResId = R.string.plans_post_purchase_button_customize;
imageResId = R.drawable.plans_customize;
break;
case PlanPostPurchaseActivity.PAGE_NUMBER_VIDEO:
titleResId = R.string.plans_post_purchase_title_video;
textResId = R.string.plans_post_purchase_text_video;
buttonResId = R.string.plans_post_purchase_button_video;
imageResId = R.drawable.plans_video_upload;
break;
case PlanPostPurchaseActivity.PAGE_NUMBER_THEMES:
titleResId = R.string.plans_post_purchase_title_themes;
textResId = R.string.plans_post_purchase_text_themes;
buttonResId = R.string.plans_post_purchase_button_themes;
imageResId = R.drawable.plans_premium_themes;
break;
default:
AppLog.w(AppLog.T.PLANS, "invalid plans post-purchase page");
throw new IllegalArgumentException("invalid plans post-purchase page");
}

txtTitle.setText(titleResId);
txtDescription.setText(textResId);
image.setImageResource(imageResId);

if (buttonResId != 0) {
button.setVisibility(View.VISIBLE);
button.setText(buttonResId);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handleButtonClick();
}
});
} else {
button.setVisibility(View.GONE);
}

return rootView;
}

private void handleButtonClick() {
switch (mPageNumber) {
case PlanPostPurchaseActivity.PAGE_NUMBER_CUSTOMIZE:
ThemeWebActivity.openCurrentTheme(getActivity(), ThemeWebActivity.ThemeWebActivityType.PREVIEW);
break;
case PlanPostPurchaseActivity.PAGE_NUMBER_THEMES:
ActivityLauncher.viewCurrentBlogThemes(getActivity());
break;
case PlanPostPurchaseActivity.PAGE_NUMBER_VIDEO:
ActivityLauncher.addNewBlogPostOrPageForResult(getActivity(), WordPress.currentBlog, false);
break;
}

// the user launched another activity, so we close this one
getActivity().finish();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
private void startPurchaseProcess() {
// TODO: this should start the Google Play purchase process, for now it shows the
// post-purchase on-boarding
boolean isBusinessPlan = (mViewPager.getCurrentItem() == mViewPager.getAdapter().getCount() - 1);
Intent intent = new Intent(this, PlanPostPurchaseActivity.class);
intent.putExtra(PlanPostPurchaseActivity.ARG_IS_BUSINESS_PLAN, isBusinessPlan);
startActivity(intent);
finish();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.app.DialogFragment;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.text.Editable;
Expand Down
Loading

0 comments on commit eff160c

Please sign in to comment.