Skip to content

Commit

Permalink
Check for login state when sharing.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Nov 12, 2015
1 parent 578a9ae commit 27078fd
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
27 changes: 20 additions & 7 deletions app/src/main/java/io/plaidapp/ui/PostNewDesignerNewsStory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }

Expand All @@ -46,17 +48,21 @@ 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);
int color = activity.getIntent().
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 27078fd

Please sign in to comment.