From 338238f4212db492620f68c4f86f213918345f5d Mon Sep 17 00:00:00 2001 From: Izzy Oji Date: Fri, 9 Mar 2018 10:54:29 -0500 Subject: [PATCH] Creator tools ref chart (#220) New creator tools referrers chart. Moving from circle graph to a bar chart using the ConstraintLayout. --- app/build.gradle | 4 + ...rDashboardReferrerBreakdownViewHolder.java | 95 +++++-- .../ui/views/ReferrerBreakdownView.java | 76 ----- ...boardReferrerBreakdownHolderViewModel.java | 47 +-- .../res/drawable/creator_dashboard_circle.xml | 5 +- .../main/res/drawable/indicator_custom.xml | 19 ++ .../main/res/drawable/indicator_external.xml | 19 ++ .../res/drawable/indicator_kickstarter.xml | 19 ++ .../dashboard_referrer_breakdown_layout.xml | 269 +++++++++++------- .../layout/dashboard_referrer_stats_view.xml | 4 +- app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/dimens.xml | 2 + ...dReferrerBreakdownHolderViewModelTest.java | 73 +---- 13 files changed, 323 insertions(+), 310 deletions(-) delete mode 100644 app/src/main/java/com/kickstarter/ui/views/ReferrerBreakdownView.java create mode 100644 app/src/main/res/drawable/indicator_custom.xml create mode 100644 app/src/main/res/drawable/indicator_external.xml create mode 100644 app/src/main/res/drawable/indicator_kickstarter.xml diff --git a/app/build.gradle b/app/build.gradle index 95b5dccd9a..717292d368 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -128,6 +128,9 @@ android { repositories { jcenter() + maven { + url 'https://maven.google.com' + } } dependencies { @@ -170,6 +173,7 @@ dependencies { compile 'net.hockeyapp.android:HockeySDK:3.6.1' compile 'org.jsoup:jsoup:1.8.2' compile "com.mixpanel.android:mixpanel-android:4.6.4" + compile 'com.android.support.constraint:constraint-layout:1.0.2' // Testing testCompile 'junit:junit:4.12' diff --git a/app/src/main/java/com/kickstarter/ui/viewholders/CreatorDashboardReferrerBreakdownViewHolder.java b/app/src/main/java/com/kickstarter/ui/viewholders/CreatorDashboardReferrerBreakdownViewHolder.java index 036419389f..32d3e42140 100644 --- a/app/src/main/java/com/kickstarter/ui/viewholders/CreatorDashboardReferrerBreakdownViewHolder.java +++ b/app/src/main/java/com/kickstarter/ui/viewholders/CreatorDashboardReferrerBreakdownViewHolder.java @@ -2,11 +2,9 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v4.graphics.drawable.DrawableCompat; +import android.support.constraint.ConstraintLayout; import android.util.Pair; import android.view.View; -import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.TextView; import com.kickstarter.R; @@ -14,12 +12,12 @@ import com.kickstarter.libs.utils.ViewUtils; import com.kickstarter.models.Project; import com.kickstarter.services.apiresponses.ProjectStatsEnvelope; -import com.kickstarter.ui.views.ReferrerBreakdownView; import com.kickstarter.viewmodels.CreatorDashboardReferrerBreakdownHolderViewModel; import java.math.RoundingMode; import butterknife.Bind; +import butterknife.BindDimen; import butterknife.ButterKnife; import static com.kickstarter.libs.rx.transformers.Transformers.observeForUI; @@ -31,17 +29,22 @@ public class CreatorDashboardReferrerBreakdownViewHolder extends KSViewHolder { protected @Bind(R.id.amount_pledged_via_kickstarter_text_view) TextView amountPledgedViaInternalTextView; protected @Bind(R.id.amount_pledged_via_external_text_view) TextView amountPledgedViaExternalTextView; protected @Bind(R.id.amount_pledged_via_custom_text_view) TextView amountPledgedViaCustomTextView; - protected @Bind(R.id.percent_via_custom_circle_text_view) ImageView percentCustomCircleTextView; protected @Bind(R.id.percent_via_custom_text_view) TextView percentCustomTextView; protected @Bind(R.id.percent_via_external_text_view) TextView percentExternalTextView; - protected @Bind(R.id.percent_via_external_circle_text_view) ImageView percentExternalCircleTextView; protected @Bind(R.id.percent_via_kickstarter_text_view) TextView percentInternalTextView; - protected @Bind(R.id.percent_via_kickstarter_circle_text_view) ImageView percentInternalCircleTextView; - protected @Bind(R.id.pledged_via_custom_layout) LinearLayout pledgedViaCustomLayout; - protected @Bind(R.id.pledged_via_external_layout) LinearLayout pledgedViaExternalLayout; - protected @Bind(R.id.pledged_via_kickstarter_layout) LinearLayout pledgedViaInternalLayout; - protected @Bind(R.id.referrer_breakdown_chart_layout) LinearLayout referrerBreakdownLayout; - protected @Bind(R.id.referrer_breakdown_view) ReferrerBreakdownView referrerBreakdownView; + protected @Bind(R.id.pledged_via_custom) View pledgedViaCustomLayout; + protected @Bind(R.id.pledged_via_custom_bar) View pledgedViaCustomBar; + protected @Bind(R.id.pledged_via_custom_indicator) View pledgedViaCustomIndicator; + protected @Bind(R.id.pledged_via_external) View pledgedViaExternalLayout; + protected @Bind(R.id.pledged_via_external_bar) View pledgedViaExternalBar; + protected @Bind(R.id.pledged_via_external_indicator) View pledgedViaExternalIndicator; + protected @Bind(R.id.pledged_via_kickstarter_bar) View pledgedViaKickstarterBar; + protected @Bind(R.id.pledged_via_kickstarter_indicator) View pledgedViaKickstarterIndicator; + protected @Bind(R.id.pledged_via_kickstarter) View pledgedViaKickstarterLayout; + protected @Bind(R.id.referrer_breakdown_chart_layout) ConstraintLayout referrerBreakdownLayout; + + protected @BindDimen(R.dimen.grid_1) int grid1Pixels; + protected @BindDimen(R.dimen.grid_3) int grid3Pixels; private KSCurrency ksCurrency; @@ -52,45 +55,35 @@ public CreatorDashboardReferrerBreakdownViewHolder(final @NonNull View view) { this.viewModel = new CreatorDashboardReferrerBreakdownHolderViewModel.ViewModel(environment()); - this.viewModel.outputs.customReferrerColor() - .compose(bindToLifecycle()) - .compose(observeForUI()) - .subscribe(color -> DrawableCompat.setTint(this.percentCustomCircleTextView.getDrawable(), color)); - this.viewModel.outputs.customReferrerPercent() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(percent -> this.referrerBreakdownView.setCustomAngleAndColor(percent * 360d)); + .subscribe(percent -> setReferrerWidth(percent, this.pledgedViaCustomBar, this.pledgedViaCustomIndicator)); this.viewModel.outputs.customReferrerPercentText() .compose(bindToLifecycle()) .compose(observeForUI()) .subscribe(this.percentCustomTextView::setText); - this.viewModel.outputs.externalReferrerColor() + this.viewModel.outputs.externalReferrerPercent() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(color -> DrawableCompat.setTint(this.percentExternalCircleTextView.getDrawable(), color)); + .subscribe(percent -> setReferrerWidth(percent, this.pledgedViaExternalBar, this.pledgedViaExternalIndicator)); this.viewModel.outputs.externalReferrerPercent() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(percent -> this.referrerBreakdownView.setExternalAngleAndColor(percent * 360d)); + .subscribe(__ -> flipIndicatorIfStatsOffScreen(this.pledgedViaExternalIndicator, this.pledgedViaExternalLayout)); this.viewModel.outputs.externalReferrerPercentText() .compose(bindToLifecycle()) .compose(observeForUI()) .subscribe(this.percentExternalTextView::setText); - this.viewModel.outputs.internalReferrerColor() - .compose(bindToLifecycle()) - .compose(observeForUI()) - .subscribe(color -> DrawableCompat.setTint(this.percentInternalCircleTextView.getDrawable(), color)); - this.viewModel.outputs.internalReferrerPercent() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(percent -> this.referrerBreakdownView.setInternalAngleAndColor(percent * 360d)); + .subscribe(percent -> setReferrerWidth(percent, this.pledgedViaKickstarterBar, this.pledgedViaKickstarterIndicator)); this.viewModel.outputs.internalReferrerPercentText() .compose(bindToLifecycle()) @@ -100,17 +93,17 @@ public CreatorDashboardReferrerBreakdownViewHolder(final @NonNull View view) { this.viewModel.outputs.pledgedViaCustomLayoutIsGone() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(ViewUtils.setGone(this.pledgedViaCustomLayout)); + .subscribe(gone -> this.hideReferrer(gone, this.pledgedViaCustomLayout, this.pledgedViaCustomBar, this.pledgedViaCustomIndicator)); this.viewModel.outputs.pledgedViaExternalLayoutIsGone() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(ViewUtils.setGone(this.pledgedViaExternalLayout)); + .subscribe(gone -> this.hideReferrer(gone, this.pledgedViaExternalLayout, this.pledgedViaExternalBar, this.pledgedViaExternalIndicator)); this.viewModel.outputs.pledgedViaInternalLayoutIsGone() .compose(bindToLifecycle()) .compose(observeForUI()) - .subscribe(ViewUtils.setGone(this.pledgedViaInternalLayout)); + .subscribe(gone -> this.hideReferrer(gone, this.pledgedViaKickstarterLayout, this.pledgedViaKickstarterBar, this.pledgedViaKickstarterIndicator)); this.viewModel.outputs.projectAndCustomReferrerPledgedAmount() .compose(bindToLifecycle()) @@ -128,6 +121,48 @@ public CreatorDashboardReferrerBreakdownViewHolder(final @NonNull View view) { .subscribe(pa -> this.setAmountPledgedTextViewText(pa, this.amountPledgedViaInternalTextView)); } + private void setReferrerWidth(final Float percent, final View bar, final View indicator) { + final ConstraintLayout.LayoutParams barLayoutParams = (ConstraintLayout.LayoutParams) bar.getLayoutParams(); + barLayoutParams.horizontalWeight = percent; + bar.setLayoutParams(barLayoutParams); + + adjustIndicatorMarginForShortBar(bar, indicator); + } + + private void adjustIndicatorMarginForShortBar(final View bar, final View indicator) { + bar.post(() -> { + if (bar.getMeasuredWidth() < this.grid3Pixels) { + final ConstraintLayout.LayoutParams indicatorLayoutParams = (ConstraintLayout.LayoutParams) indicator.getLayoutParams(); + indicatorLayoutParams.startToStart = bar.getId(); + indicatorLayoutParams.endToEnd = bar.getId(); + indicator.setLayoutParams(indicatorLayoutParams); + } + }); + } + + private void flipIndicatorIfStatsOffScreen(final View indicator, final View stats) { + stats.post(() -> { + if (stats.getLeft() < this.referrerBreakdownLayout.getLeft()) { + indicator.setScaleX(-1); + final ConstraintLayout.LayoutParams indicatorLayoutParams = (ConstraintLayout.LayoutParams) indicator.getLayoutParams(); + indicatorLayoutParams.setMarginStart(this.grid3Pixels); + indicator.setLayoutParams(indicatorLayoutParams); + + final ConstraintLayout.LayoutParams statsLayoutParams = (ConstraintLayout.LayoutParams) stats.getLayoutParams(); + statsLayoutParams.startToEnd = indicator.getId(); + statsLayoutParams.setMarginStart(this.grid1Pixels); + statsLayoutParams.endToStart = ConstraintLayout.LayoutParams.UNSET; + stats.setLayoutParams(statsLayoutParams); + } + }); + } + + private void hideReferrer(final boolean gone, final @NonNull View layout, final @NonNull View bar, final @NonNull View indicator) { + ViewUtils.setGone(layout, gone); + ViewUtils.setGone(bar, gone); + ViewUtils.setGone(indicator, gone); + } + @Override public void bindData(final @Nullable Object data) throws Exception { final Pair projectAndStats = requireNonNull((Pair) data); diff --git a/app/src/main/java/com/kickstarter/ui/views/ReferrerBreakdownView.java b/app/src/main/java/com/kickstarter/ui/views/ReferrerBreakdownView.java deleted file mode 100644 index ec66d7802b..0000000000 --- a/app/src/main/java/com/kickstarter/ui/views/ReferrerBreakdownView.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.kickstarter.ui.views; - -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.RectF; -import android.support.annotation.NonNull; -import android.util.AttributeSet; -import android.view.View; - -import com.kickstarter.libs.ReferrerColor; - -public final class ReferrerBreakdownView extends View { - - public Canvas canvas; - private Double customSweepAngle; - private Double externalSweepAngle; - private Double internalSweepAngle; - private RectF outerRectangle; - private RectF innerRectangle; - private Paint paint; - private static final int innerCircleOffset = 30; - - public ReferrerBreakdownView(final @NonNull Context context, final @NonNull AttributeSet attributeSet) { - super(context, attributeSet); - this.paint = new Paint(); - this.outerRectangle = new RectF(0, 0, 0, 0); - this.innerRectangle = new RectF(0, 0, 0, 0); - } - - public void setCustomAngleAndColor(final @NonNull Double sweepAngle) { - this.customSweepAngle = sweepAngle; - } - - public void setExternalAngleAndColor(final @NonNull Double sweepAngle) { - this.externalSweepAngle = sweepAngle; - } - - public void setInternalAngleAndColor(final @NonNull Double sweepAngle) { - this.internalSweepAngle = sweepAngle; - } - - @Override - protected void onDraw(final @NonNull Canvas canvas) { - super.onDraw(canvas); - this.canvas = canvas; - - this.paint.setAntiAlias(true); - this.paint.setStyle(Paint.Style.FILL); - - final float bottom = getHeight(); - final float left = getX(); - final float right = getWidth(); - final float top = getY(); - - this.outerRectangle.set(left, top, right, bottom); - this.innerRectangle.set(left + innerCircleOffset, top + innerCircleOffset, right - innerCircleOffset, bottom - innerCircleOffset); - - Float offset = 0f; - - this.paint.setColor(ReferrerColor.CUSTOM.getReferrerColor()); - this.canvas.drawArc(this.outerRectangle, offset, this.customSweepAngle.floatValue(), true, this.paint); - offset = offset + this.customSweepAngle.floatValue(); - - this.paint.setColor(ReferrerColor.EXTERNAL.getReferrerColor()); - this.canvas.drawArc(this.outerRectangle, offset, this.externalSweepAngle.floatValue(), true, this.paint); - offset = offset + this.externalSweepAngle.floatValue(); - - this.paint.setColor(ReferrerColor.INTERNAL.getReferrerColor()); - this.canvas.drawArc(this.outerRectangle, offset, this.internalSweepAngle.floatValue(), true, this.paint); - - this.paint.setColor(Color.WHITE); - this.canvas.drawArc(this.innerRectangle, 0, 360f, true, this.paint); - } -} diff --git a/app/src/main/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModel.java b/app/src/main/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModel.java index d0660e45f5..15c6e40fc5 100644 --- a/app/src/main/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModel.java +++ b/app/src/main/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModel.java @@ -5,7 +5,6 @@ import com.kickstarter.libs.ActivityViewModel; import com.kickstarter.libs.Environment; -import com.kickstarter.libs.ReferrerColor; import com.kickstarter.libs.ReferrerType; import com.kickstarter.libs.utils.NumberUtils; import com.kickstarter.libs.utils.PairUtils; @@ -18,8 +17,6 @@ import rx.Observable; import rx.subjects.PublishSubject; -import static com.kickstarter.libs.rx.transformers.Transformers.takeWhen; - public interface CreatorDashboardReferrerBreakdownHolderViewModel { interface Inputs { @@ -28,27 +25,18 @@ interface Inputs { } interface Outputs { - /** Emits the color for the custom referrers on the pie chart **/ - Observable customReferrerColor(); - /** Emits the percentage of total pledges from a custom referrer **/ Observable customReferrerPercent(); /** Emits the text for the percentage of total pledges from a custom referrer **/ Observable customReferrerPercentText(); - /** Emits the color for the external referrers on the pie chart **/ - Observable externalReferrerColor(); - /** Emits the percentage of total pledges from a external referrer **/ Observable externalReferrerPercent(); /** Emits the text for the percentage of total pledges from an external referrer **/ Observable externalReferrerPercentText(); - /** Emits the color for the internal referrers on the pie chart **/ - Observable internalReferrerColor(); - /** Emits the percentage of total pledges from an internal referrer **/ Observable internalReferrerPercent(); @@ -75,9 +63,6 @@ interface Outputs { /** Emits the current project and the amount pledged via internal referrers **/ Observable> projectAndInternalReferrerPledgedAmount(); - - /** Emits when there are more than 10 referrer stats and title copy should reflect limited list. */ - Observable referrersTitleIsLimitedCopy(); } final class ViewModel extends ActivityViewModel implements Inputs, Outputs { @@ -117,9 +102,6 @@ public ViewModel(final @NonNull Environment environment) { this.projectAndAveragePledge = Observable.combineLatest(currentProject, averagePledge, Pair::create); - this.customReferrerColor = Observable.just(ReferrerColor.CUSTOM.getReferrerColor()) - .compose(takeWhen(customReferrers)); - this.customReferrerPercent = customReferrers .flatMap(rs -> Observable.from(rs) @@ -127,7 +109,7 @@ public ViewModel(final @NonNull Environment environment) { ); this.customReferrerPercentText = this.customReferrerPercent - .map(percent -> NumberUtils.flooredPercentage(percent.floatValue() * 100f)); + .map(percent -> NumberUtils.flooredPercentage(percent * 100f)); this.customReferrerPledgedAmount = customReferrers .flatMap(rs -> @@ -141,9 +123,6 @@ public ViewModel(final @NonNull Environment environment) { Pair::create ); - this.externalReferrerColor = Observable.just(ReferrerColor.EXTERNAL.getReferrerColor()) - .compose(takeWhen(externalReferrers)); - this.externalReferrerPercent = externalReferrers .flatMap(rs -> Observable.from(rs) @@ -165,9 +144,6 @@ public ViewModel(final @NonNull Environment environment) { Pair::create ); - this.internalReferrerColor = Observable.just(ReferrerColor.INTERNAL.getReferrerColor()) - .compose(takeWhen(internalReferrers)); - this.internalReferrerPercent = internalReferrers .flatMap(rs -> Observable.from(rs) @@ -175,7 +151,7 @@ public ViewModel(final @NonNull Environment environment) { ); this.internalReferrerPercentText = this.internalReferrerPercent - .map(percent -> NumberUtils.flooredPercentage(percent.floatValue() * 100f)); + .map(percent -> NumberUtils.flooredPercentage(percent * 100f)); this.internalReferrerPledgedAmount = internalReferrers .flatMap(rs -> @@ -210,15 +186,12 @@ public ViewModel(final @NonNull Environment environment) { private final PublishSubject> projectAndProjectStatsInput = PublishSubject.create(); - private final Observable customReferrerColor; private final Observable customReferrerPercent; private final Observable customReferrerPercentText; private final Observable customReferrerPledgedAmount; - private final Observable externalReferrerColor; private final Observable externalReferrerPercent; private final Observable externalReferrerPercentText; private final Observable externalReferrerPledgedAmount; - private final Observable internalReferrerColor; private final Observable internalReferrerPercent; private final Observable internalReferrerPercentText; private final Observable internalReferrerPledgedAmount; @@ -236,11 +209,6 @@ public void projectAndStatsInput(final @NonNull Pair customReferrerColor() { - return this.customReferrerColor; - } @Override public @NonNull Observable customReferrerPercent() { return this.customReferrerPercent; @@ -250,10 +218,6 @@ public void projectAndStatsInput(final @NonNull Pair externalReferrerColor() { - return this.externalReferrerColor; - } - @Override public @NonNull Observable externalReferrerPercent() { return this.externalReferrerPercent; } @@ -262,10 +226,6 @@ public void projectAndStatsInput(final @NonNull Pair internalReferrerColor() { - return this.internalReferrerColor; - } - @Override public @NonNull Observable internalReferrerPercent() { return this.internalReferrerPercent; } @@ -301,8 +261,5 @@ public void projectAndStatsInput(final @NonNull Pair> projectAndInternalReferrerPledgedAmount() { return this.projectAndInternalReferrerPledgedAmount; } - @Override public @NonNull Observable referrersTitleIsLimitedCopy() { - return this.referrersTitleIsLimitedCopy; - } } } diff --git a/app/src/main/res/drawable/creator_dashboard_circle.xml b/app/src/main/res/drawable/creator_dashboard_circle.xml index 76ab42e102..cb23dedc41 100644 --- a/app/src/main/res/drawable/creator_dashboard_circle.xml +++ b/app/src/main/res/drawable/creator_dashboard_circle.xml @@ -1,6 +1,9 @@ + + android:color="@android:color/white" /> diff --git a/app/src/main/res/drawable/indicator_custom.xml b/app/src/main/res/drawable/indicator_custom.xml new file mode 100644 index 0000000000..dc7da66210 --- /dev/null +++ b/app/src/main/res/drawable/indicator_custom.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/app/src/main/res/drawable/indicator_external.xml b/app/src/main/res/drawable/indicator_external.xml new file mode 100644 index 0000000000..475a2a6f06 --- /dev/null +++ b/app/src/main/res/drawable/indicator_external.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/app/src/main/res/drawable/indicator_kickstarter.xml b/app/src/main/res/drawable/indicator_kickstarter.xml new file mode 100644 index 0000000000..922a16033a --- /dev/null +++ b/app/src/main/res/drawable/indicator_kickstarter.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/app/src/main/res/layout/dashboard_referrer_breakdown_layout.xml b/app/src/main/res/layout/dashboard_referrer_breakdown_layout.xml index 686c8c0588..ce2b7d5973 100644 --- a/app/src/main/res/layout/dashboard_referrer_breakdown_layout.xml +++ b/app/src/main/res/layout/dashboard_referrer_breakdown_layout.xml @@ -1,174 +1,251 @@ + android:showDividers="beginning"> + android:text="@string/How_backers_found_your_project" /> - - - + android:paddingEnd="@dimen/grid_2" + android:paddingStart="@dimen/grid_2"> + + + + + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:layout_marginStart="@dimen/grid_1" + android:layout_marginTop="@dimen/grid_8" + android:orientation="vertical" + app:layout_constraintStart_toEndOf="@+id/pledged_via_kickstarter_indicator" + app:layout_constraintTop_toTopOf="@+id/pledged_via_kickstarter_bar"> - - - + android:layout_gravity="center_vertical" + android:layout_marginEnd="1dp" + android:src="@drawable/creator_dashboard_circle" + android:tint="@color/ksr_green_800" + tools:ignore="ContentDescription" /> + + - + - + - + - + + + + + - + - + - + - + - + + + - + - + android:layout_marginBottom="@dimen/grid_1_half"> - + - + - + - - - + + + + diff --git a/app/src/main/res/layout/dashboard_referrer_stats_view.xml b/app/src/main/res/layout/dashboard_referrer_stats_view.xml index c3a79a7307..677fcb7eda 100644 --- a/app/src/main/res/layout/dashboard_referrer_stats_view.xml +++ b/app/src/main/res/layout/dashboard_referrer_stats_view.xml @@ -5,9 +5,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/grid_5" - android:divider="@drawable/divider_dark_grey_500_horizontal" - android:orientation="vertical" - android:showDividers="beginning"> + android:orientation="vertical"> #395AEB #9B9E9E #656969 + #05F2BA #009E74 #037362 #034752 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c61fd1de2c..70668703f7 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -17,12 +17,14 @@ 48dp 54dp 60dp + 64dp 63dp 72dp 78dp 84dp 90dp 96dp + 102dp 120dp 126dp 162dp diff --git a/app/src/test/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModelTest.java b/app/src/test/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModelTest.java index 66c6b6b781..87ce838a4c 100644 --- a/app/src/test/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModelTest.java +++ b/app/src/test/java/com/kickstarter/viewmodels/CreatorDashboardReferrerBreakdownHolderViewModelTest.java @@ -7,7 +7,6 @@ import com.kickstarter.factories.ProjectFactory; import com.kickstarter.factories.ProjectStatsEnvelopeFactory; import com.kickstarter.libs.Environment; -import com.kickstarter.libs.ReferrerColor; import com.kickstarter.libs.ReferrerType; import com.kickstarter.libs.utils.NumberUtils; import com.kickstarter.models.Project; @@ -16,6 +15,7 @@ import org.junit.Test; import java.util.Arrays; +import java.util.Collections; import java.util.List; import rx.observers.TestSubscriber; @@ -26,11 +26,8 @@ public class CreatorDashboardReferrerBreakdownHolderViewModelTest extends KSRobo private final TestSubscriber customReferrerPercent = new TestSubscriber<>(); private final TestSubscriber externalReferrerPercent = new TestSubscriber<>(); private final TestSubscriber internalReferrerPercent = new TestSubscriber<>(); - private final TestSubscriber customReferrerColor = new TestSubscriber<>(); private final TestSubscriber customReferrerPercentText = new TestSubscriber<>(); - private final TestSubscriber externalReferrerColor = new TestSubscriber<>(); private final TestSubscriber externalReferrerPercentText = new TestSubscriber<>(); - private final TestSubscriber internalReferrerColor = new TestSubscriber<>(); private final TestSubscriber internalReferrerPercentText = new TestSubscriber<>(); private final TestSubscriber pledgedViaCustomLayoutIsGone = new TestSubscriber<>(); private final TestSubscriber pledgedViaExternalLayoutIsGone = new TestSubscriber<>(); @@ -42,13 +39,10 @@ public class CreatorDashboardReferrerBreakdownHolderViewModelTest extends KSRobo protected void setUpEnvironment(final @NonNull Environment environment) { this.vm = new CreatorDashboardReferrerBreakdownHolderViewModel.ViewModel(environment); - this.vm.outputs.customReferrerColor().subscribe(this.customReferrerColor); this.vm.outputs.customReferrerPercent().subscribe(this.customReferrerPercent); this.vm.outputs.customReferrerPercentText().subscribe(this.customReferrerPercentText); - this.vm.outputs.externalReferrerColor().subscribe(this.externalReferrerColor); this.vm.outputs.externalReferrerPercent().subscribe(this.externalReferrerPercent); this.vm.outputs.externalReferrerPercentText().subscribe(this.externalReferrerPercentText); - this.vm.outputs.internalReferrerColor().subscribe(this.internalReferrerColor); this.vm.outputs.internalReferrerPercent().subscribe(this.internalReferrerPercent); this.vm.outputs.internalReferrerPercentText().subscribe(this.internalReferrerPercentText); this.vm.outputs.pledgedViaCustomLayoutIsGone().subscribe(this.pledgedViaCustomLayoutIsGone); @@ -60,16 +54,6 @@ protected void setUpEnvironment(final @NonNull Environment environment) { this.vm.outputs.projectAndInternalReferrerPledgedAmount().subscribe(this.projectAndInternalReferrerPledgedAmount); } - @Test - public void testCustomReferrerColor() { - final Project project = ProjectFactory.project(); - final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope(); - - setUpEnvironment(environment()); - this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.customReferrerColor.assertValues(ReferrerColor.CUSTOM.getReferrerColor()); - } - @Test public void testCustomReferrerPercent() { final Project project = ProjectFactory.project(); @@ -77,8 +61,7 @@ public void testCustomReferrerPercent() { .percentageOfDollars(55f) .referrerType(ReferrerType.CUSTOM.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - fiftyFivePercentCustomReferrer); + final List referrerList = Collections.singletonList(fiftyFivePercentCustomReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -93,8 +76,7 @@ public void testCustomReferrerPercentText() { .percentageOfDollars(.55f) .referrerType(ReferrerType.CUSTOM.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - fiftyFivePercentCustomReferrer); + final List referrerList = Collections.singletonList(fiftyFivePercentCustomReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -102,16 +84,6 @@ public void testCustomReferrerPercentText() { this.customReferrerPercentText.assertValues("55%"); } - @Test - public void testExternalReferrerColor() { - final Project project = ProjectFactory.project(); - final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope(); - - setUpEnvironment(environment()); - this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.externalReferrerColor.assertValues(ReferrerColor.EXTERNAL.getReferrerColor()); - } - @Test public void testExternalReferrerPercent() { final Project project = ProjectFactory.project(); @@ -119,8 +91,7 @@ public void testExternalReferrerPercent() { .percentageOfDollars(15f) .referrerType(ReferrerType.EXTERNAL.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - fifteenPercentExternalReferrer); + final List referrerList = Collections.singletonList(fifteenPercentExternalReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -135,8 +106,7 @@ public void testExternalReferrerPercentText() { .percentageOfDollars(15f) .referrerType(ReferrerType.EXTERNAL.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - fifteenPercentExternalReferrer); + final List referrerList = Collections.singletonList(fifteenPercentExternalReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -144,16 +114,6 @@ public void testExternalReferrerPercentText() { this.externalReferrerPercentText.assertValues(NumberUtils.flooredPercentage(15f * 100f)); } - @Test - public void testInternalReferrerColor() { - final Project project = ProjectFactory.project(); - final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope(); - - setUpEnvironment(environment()); - this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.internalReferrerColor.assertValues(ReferrerColor.INTERNAL.getReferrerColor()); - } - @Test public void testInternalReferrerPercent() { final Project project = ProjectFactory.project(); @@ -161,8 +121,7 @@ public void testInternalReferrerPercent() { .percentageOfDollars(30f) .referrerType(ReferrerType.INTERNAL.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - thirtyPercentInternalReferrer); + final List referrerList = Collections.singletonList(thirtyPercentInternalReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -177,8 +136,7 @@ public void testInternalReferrerPercentText() { .percentageOfDollars(30f) .referrerType(ReferrerType.INTERNAL.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - thirtyPercentInternalReferrer); + final List referrerList = Collections.singletonList(thirtyPercentInternalReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -193,8 +151,7 @@ public void testPledgedViaCustomLayoutIsGone() { .pledged(0f) .referrerType(ReferrerType.CUSTOM.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - zeroPledgedCustomReferrer); + final List referrerList = Collections.singletonList(zeroPledgedCustomReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -209,8 +166,7 @@ public void testPledgedViaExternalLayoutIsGone() { .pledged(0f) .referrerType(ReferrerType.EXTERNAL.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - zeroPledgedExternalReferrer); + final List referrerList = Collections.singletonList(zeroPledgedExternalReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -225,8 +181,7 @@ public void testPledgedViaInternalLayoutIsGone() { .pledged(0f) .referrerType(ReferrerType.INTERNAL.getReferrerType()) .build(); - final List referrerList = Arrays.asList( - zeroPledgedInternalReferrer); + final List referrerList = Collections.singletonList(zeroPledgedInternalReferrer); final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().referralDistribution(referrerList).build(); setUpEnvironment(environment()); @@ -244,7 +199,7 @@ public void testProjectAndAveragePledge() { final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().cumulative(cumulativeStats).build(); setUpEnvironment(environment()); this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.projectAndAveragePledge.assertValues(Pair.create(project, 10)); + this.projectAndAveragePledge.assertValue(Pair.create(project, 10)); } @Test @@ -268,7 +223,7 @@ public void testProjectAndCustomReferrerPledgedAmount() { setUpEnvironment(environment()); this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.projectAndCustomReferrerPledgedAmount.assertValues(Pair.create(project, 3f)); + this.projectAndCustomReferrerPledgedAmount.assertValue(Pair.create(project, 3f)); } @Test @@ -292,7 +247,7 @@ public void testProjectAndExternalReferrerPledgedAmount() { setUpEnvironment(environment()); this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.projectAndExternalReferrerPledgedAmount.assertValues(Pair.create(project, 3f)); + this.projectAndExternalReferrerPledgedAmount.assertValue(Pair.create(project, 3f)); } @Test @@ -316,7 +271,7 @@ public void testProjectAndInternalReferrerPledgedAmount() { setUpEnvironment(environment()); this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope)); - this.projectAndInternalReferrerPledgedAmount.assertValues(Pair.create(project, 2f)); + this.projectAndInternalReferrerPledgedAmount.assertValue(Pair.create(project, 2f)); } @Test