diff --git a/app/src/main/java/io/plaidapp/ui/PostNewDesignerNewsStory.java b/app/src/main/java/io/plaidapp/ui/PostNewDesignerNewsStory.java index 267d25882..939f1d005 100644 --- a/app/src/main/java/io/plaidapp/ui/PostNewDesignerNewsStory.java +++ b/app/src/main/java/io/plaidapp/ui/PostNewDesignerNewsStory.java @@ -17,10 +17,12 @@ package io.plaidapp.ui; import android.app.Activity; +import android.app.ActivityOptions; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TextInputLayout; import android.support.v4.app.ShareCompat; +import android.support.v4.content.ContextCompat; import android.text.TextUtils; import android.view.KeyEvent; import android.view.ViewGroup; @@ -38,6 +40,7 @@ import butterknife.OnEditorAction; import butterknife.OnTextChanged; import io.plaidapp.R; +import io.plaidapp.data.prefs.DesignerNewsPrefs; import io.plaidapp.ui.transitions.FabDialogMorphSetup; import io.plaidapp.ui.widget.BottomSheet; import io.plaidapp.ui.widget.ObservableScrollView; @@ -178,13 +181,23 @@ protected void commentTextChanged(CharSequence text) { @OnClick(R.id.new_story_post) protected void postNewStory() { - ImeUtils.hideIme(title); - Intent data = new Intent(); - data.putExtra(EXTRA_STORY_TITLE, title.getText().toString()); - data.putExtra(EXTRA_STORY_URL, url.getText().toString()); - data.putExtra(EXTRA_STORY_COMMENT, comment.getText().toString()); - setResult(RESULT_POST, data); - finishAfterTransition(); + if (DesignerNewsPrefs.get(this).isLoggedIn()) { + ImeUtils.hideIme(title); + Intent data = new Intent(); + data.putExtra(EXTRA_STORY_TITLE, title.getText().toString()); + data.putExtra(EXTRA_STORY_URL, url.getText().toString()); + data.putExtra(EXTRA_STORY_COMMENT, comment.getText().toString()); + setResult(RESULT_POST, data); + finishAfterTransition(); + } else { + Intent login = new Intent(this, DesignerNewsLogin.class); + login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_COLOR, + ContextCompat.getColor(this, R.color.designer_news)); + login.putExtra(FabDialogMorphSetup.EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, 0); + ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation( + this, post, getString(R.string.transition_designer_news_login)); + startActivity(login, options.toBundle()); + } } private void setPostButtonState() { diff --git a/app/src/main/java/io/plaidapp/ui/transitions/FabDialogMorphSetup.java b/app/src/main/java/io/plaidapp/ui/transitions/FabDialogMorphSetup.java index 7dbf9b91e..5189606f5 100644 --- a/app/src/main/java/io/plaidapp/ui/transitions/FabDialogMorphSetup.java +++ b/app/src/main/java/io/plaidapp/ui/transitions/FabDialogMorphSetup.java @@ -32,6 +32,8 @@ public class FabDialogMorphSetup { public static final String EXTRA_SHARED_ELEMENT_START_COLOR = "EXTRA_SHARED_ELEMENT_START_COLOR"; + public static final String EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS = + "EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS"; private FabDialogMorphSetup() { } @@ -46,6 +48,9 @@ public static void setupSharedEelementTransitions(@NonNull Activity activity, int dialogCornerRadius) { if (!activity.getIntent().hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR)) return; + int startCornerRadius = activity.getIntent().getIntExtra + (EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, -1); + ArcMotion arcMotion = new ArcMotion(); arcMotion.setMinimumHorizontalAngle(50f); arcMotion.setMinimumVerticalAngle(50f); @@ -53,10 +58,11 @@ public static void setupSharedEelementTransitions(@NonNull Activity activity, getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT); Interpolator easeInOut = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in); - MorphFabToDialog sharedEnter = new MorphFabToDialog(color, dialogCornerRadius); + MorphFabToDialog sharedEnter = + new MorphFabToDialog(color, dialogCornerRadius, startCornerRadius); sharedEnter.setPathMotion(arcMotion); sharedEnter.setInterpolator(easeInOut); - MorphDialogToFab sharedReturn = new MorphDialogToFab(color); + MorphDialogToFab sharedReturn = new MorphDialogToFab(color, startCornerRadius); sharedReturn.setPathMotion(arcMotion); sharedReturn.setInterpolator(easeInOut); if (target != null) { diff --git a/app/src/main/java/io/plaidapp/ui/transitions/MorphDialogToFab.java b/app/src/main/java/io/plaidapp/ui/transitions/MorphDialogToFab.java index fe658130f..ce3cdd3af 100644 --- a/app/src/main/java/io/plaidapp/ui/transitions/MorphDialogToFab.java +++ b/app/src/main/java/io/plaidapp/ui/transitions/MorphDialogToFab.java @@ -46,12 +46,19 @@ public class MorphDialogToFab extends ChangeBounds { PROPERTY_CORNER_RADIUS }; private @ColorInt int endColor = Color.TRANSPARENT; + private int endCornerRadius = -1; public MorphDialogToFab(@ColorInt int endColor) { super(); setEndColor(endColor); } + public MorphDialogToFab(@ColorInt int endColor, int endCornerRadius) { + super(); + setEndColor(endColor); + setEndCornerRadius(endCornerRadius); + } + public MorphDialogToFab(Context context, AttributeSet attrs) { super(context, attrs); } @@ -60,6 +67,10 @@ public void setEndColor(@ColorInt int endColor) { this.endColor = endColor; } + public void setEndCornerRadius(int endCornerRadius) { + this.endCornerRadius = endCornerRadius; + } + @Override public String[] getTransitionProperties() { return TRANSITION_PROPERTIES; @@ -86,7 +97,8 @@ public void captureEndValues(TransitionValues transitionValues) { return; } transitionValues.values.put(PROPERTY_COLOR, endColor); - transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getHeight() / 2); + transitionValues.values.put(PROPERTY_CORNER_RADIUS, + endCornerRadius >= 0 ? endCornerRadius : view.getHeight() / 2); } @Override diff --git a/app/src/main/java/io/plaidapp/ui/transitions/MorphFabToDialog.java b/app/src/main/java/io/plaidapp/ui/transitions/MorphFabToDialog.java index b82f614e4..5bedfea5a 100644 --- a/app/src/main/java/io/plaidapp/ui/transitions/MorphFabToDialog.java +++ b/app/src/main/java/io/plaidapp/ui/transitions/MorphFabToDialog.java @@ -46,11 +46,17 @@ public class MorphFabToDialog extends ChangeBounds { }; private @ColorInt int startColor = Color.TRANSPARENT; private int endCornerRadius; + private int startCornerRadius; public MorphFabToDialog(@ColorInt int startColor, int endCornerRadius) { + this(startColor, endCornerRadius, -1); + } + + public MorphFabToDialog(@ColorInt int startColor, int endCornerRadius, int startCornerRadius) { super(); setStartColor(startColor); setEndCornerRadius(endCornerRadius); + setStartCornerRadius(startCornerRadius); } public MorphFabToDialog(Context context, AttributeSet attrs) { @@ -65,6 +71,10 @@ public void setEndCornerRadius(int endCornerRadius) { this.endCornerRadius = endCornerRadius; } + public void setStartCornerRadius(int startCornerRadius) { + this.startCornerRadius = startCornerRadius; + } + @Override public String[] getTransitionProperties() { return TRANSITION_PROPERTIES; @@ -78,7 +88,8 @@ public void captureStartValues(TransitionValues transitionValues) { return; } transitionValues.values.put(PROPERTY_COLOR, startColor); - transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getHeight() / 2); + transitionValues.values.put(PROPERTY_CORNER_RADIUS, + startCornerRadius >= 0 ? startCornerRadius : view.getHeight() / 2); } @Override