From 39698a47236ace7b1691edbf9bb67188ccbaf6e4 Mon Sep 17 00:00:00 2001 From: Kosh Date: Sat, 11 Mar 2017 16:40:28 +0800 Subject: [PATCH] removed follow menuItem and used Button instead, now filling star, fork & watch icons upon interacting with them to close #96 and improved 'again' contribution guide to close #114 --- app/src/debuggingApp/gradle.properties | 2 +- .../com/fastaccess/helper/AnimHelper.java | 28 +- .../profile/overview/ProfileOverviewMvp.java | 13 + .../overview/ProfileOverviewPresenter.java | 44 ++- .../profile/overview/ProfileOverviewView.java | 40 +- .../ui/modules/repos/RepoPagerView.java | 9 +- .../ui/modules/user/UserPagerMvp.java | 16 +- .../ui/modules/user/UserPagerPresenter.java | 40 +- .../ui/modules/user/UserPagerView.java | 45 --- .../fastaccess/ui/widgets/FontTextView.java | 6 + app/src/main/res/animator/fill_to_star.xml | 9 + app/src/main/res/animator/minus_to_plus.xml | 9 + .../main/res/animator/plus_minus_rotate.xml | 8 + app/src/main/res/animator/plus_to_minus.xml | 9 + app/src/main/res/animator/star_to_fill.xml | 9 + app/src/main/res/drawable/asl_follow.xml | 24 ++ app/src/main/res/drawable/avd_follow.xml | 14 + app/src/main/res/drawable/avd_unfollow.xml | 14 + app/src/main/res/drawable/ic_follow.xml | 26 ++ app/src/main/res/drawable/ic_fork.xml | 1 - app/src/main/res/drawable/ic_fork_filled.xml | 352 ++++++++++++++++++ app/src/main/res/drawable/ic_star_filled.xml | 9 + app/src/main/res/drawable/ic_unfollow.xml | 26 ++ .../layout/profile_overview_layout.xml | 16 + app/src/main/res/menu/follow_menu.xml | 9 - app/src/main/res/values/paths.xml | 6 + 26 files changed, 656 insertions(+), 128 deletions(-) create mode 100644 app/src/main/res/animator/fill_to_star.xml create mode 100644 app/src/main/res/animator/minus_to_plus.xml create mode 100644 app/src/main/res/animator/plus_minus_rotate.xml create mode 100644 app/src/main/res/animator/plus_to_minus.xml create mode 100644 app/src/main/res/animator/star_to_fill.xml create mode 100644 app/src/main/res/drawable/asl_follow.xml create mode 100644 app/src/main/res/drawable/avd_follow.xml create mode 100644 app/src/main/res/drawable/avd_unfollow.xml create mode 100644 app/src/main/res/drawable/ic_follow.xml create mode 100644 app/src/main/res/drawable/ic_fork_filled.xml create mode 100644 app/src/main/res/drawable/ic_star_filled.xml create mode 100644 app/src/main/res/drawable/ic_unfollow.xml delete mode 100644 app/src/main/res/menu/follow_menu.xml create mode 100644 app/src/main/res/values/paths.xml diff --git a/app/src/debuggingApp/gradle.properties b/app/src/debuggingApp/gradle.properties index 56d0810f..256877ef 100644 --- a/app/src/debuggingApp/gradle.properties +++ b/app/src/debuggingApp/gradle.properties @@ -4,4 +4,4 @@ ANDROID_KEY_PASSWORD=PASSWORD ANDROID_KEY_ALIAS=ALIAS GITHUB_CLIENT_ID=GITHUB_CLIENT_ID GITHUB_SECRET=GITHUB_SECRET -REDIRECT_URL=REDIRECT_URL \ No newline at end of file +REDIRECT_URL=https://127.0.0.1 \ No newline at end of file diff --git a/app/src/main/java/com/fastaccess/helper/AnimHelper.java b/app/src/main/java/com/fastaccess/helper/AnimHelper.java index e566f966..9e77a189 100644 --- a/app/src/main/java/com/fastaccess/helper/AnimHelper.java +++ b/app/src/main/java/com/fastaccess/helper/AnimHelper.java @@ -27,7 +27,7 @@ import java.util.List; public class AnimHelper { - interface AnimationCallback { + public interface AnimationCallback { void onAnimationEnd(); void onAnimationStart(); @@ -35,12 +35,21 @@ public class AnimHelper { private static final Interpolator interpolator = new LinearInterpolator(); - @UiThread public static void animateVisibility(@Nullable final View view, final boolean show) { - animateVisibility(view, show, null); + @UiThread public static void animateVisibility(@Nullable final View view, final boolean show, int visibility) { + animateVisibility(view, show, visibility, null); } - @SuppressWarnings("WeakerAccess") @UiThread - public static void animateVisibility(@Nullable final View view, final boolean show, @Nullable final AnimationCallback callback) { + @UiThread public static void animateVisibility(@Nullable final View view, final boolean show) { + animateVisibility(view, show, View.GONE); + } + + @UiThread public static void animateVisibility(@Nullable final View view, final boolean show, + @Nullable final AnimationCallback callback) { + animateVisibility(view, show, View.GONE, callback); + } + + @UiThread public static void animateVisibility(@Nullable final View view, final boolean show, int visibility, + @Nullable final AnimationCallback callback) { if (view == null) { return; } @@ -48,16 +57,17 @@ public class AnimHelper { view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { view.getViewTreeObserver().removeOnPreDrawListener(this); - animateSafeVisibility(show, view, callback); + animateSafeVisibility(show, view, visibility, callback); return true; } }); } else { - animateSafeVisibility(show, view, callback); + animateSafeVisibility(show, view, visibility, callback); } } - @UiThread private static void animateSafeVisibility(final boolean show, @NonNull final View view, @Nullable final AnimationCallback callback) { + @UiThread private static void animateSafeVisibility(final boolean show, @NonNull final View view, int visibility, + @Nullable final AnimationCallback callback) { view.clearAnimation(); if (view.getAnimation() != null) view.getAnimation().cancel(); ViewPropertyAnimator animator = view.animate().setDuration(200).alpha(show ? 1F : 0F).setInterpolator(new AccelerateInterpolator()) @@ -75,7 +85,7 @@ public class AnimHelper { @Override public void onAnimationEnd(@NonNull Animator animation) { super.onAnimationEnd(animation); if (!show) { - view.setVisibility(View.GONE); + view.setVisibility(visibility); view.setScaleX(0); view.setScaleY(0); } diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewMvp.java b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewMvp.java index d0383879..801d66e6 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewMvp.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewMvp.java @@ -15,13 +15,26 @@ interface ProfileOverviewMvp { interface View extends BaseMvp.FAView { void onInitViews(@Nullable UserModel userModel); + void onInvalidateMenuItem(); } interface Presenter extends BaseMvp.FAPresenter { + + void onFragmentCreated(@Nullable Bundle bundle); void onWorkOffline(@NonNull String login); + void onCheckFollowStatus(@NonNull String login); + + boolean isSuccessResponse(); + + boolean isFollowing(); + + void onFollowButtonClicked(@NonNull String login); + void onSendUserToView(@Nullable UserModel userModel); + + @NonNull String getLogin(); } } diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewPresenter.java b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewPresenter.java index 3c79ce97..393588f5 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewPresenter.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewPresenter.java @@ -3,27 +3,60 @@ package com.fastaccess.ui.modules.profile.overview; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.text.TextUtils; +import com.fastaccess.data.dao.LoginModel; import com.fastaccess.data.dao.UserModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.InputHelper; +import com.fastaccess.helper.RxHelper; import com.fastaccess.provider.rest.RestProvider; import com.fastaccess.ui.base.mvp.presenter.BasePresenter; -import rx.Observable; - /** * Created by Kosh on 03 Dec 2016, 9:16 AM */ class ProfileOverviewPresenter extends BasePresenter implements ProfileOverviewMvp.Presenter { - + private boolean isSuccessResponse; + private boolean isFollowing; private String login; + + @Override public void onCheckFollowStatus(@NonNull String login) { + if (!TextUtils.equals(login, LoginModel.getUser().getLogin())) + makeRestCall(RestProvider.getUserService().getFollowStatus(login), + booleanResponse -> { + isSuccessResponse = true; + isFollowing = booleanResponse.code() == 204; + sendToView(ProfileOverviewMvp.View::onInvalidateMenuItem); + }); + } + + @Override public boolean isSuccessResponse() { + return isSuccessResponse; + } + + @Override public boolean isFollowing() { + return isFollowing; + } + + @Override public void onFollowButtonClicked(@NonNull String login) { + manageSubscription(RxHelper.getObserver(!isFollowing ? RestProvider.getUserService().followUser(login) + : RestProvider.getUserService().unfollowUser(login)) + .subscribe(booleanResponse -> { + if (booleanResponse.code() == 204) { + isFollowing = !isFollowing; + sendToView(ProfileOverviewMvp.View::onInvalidateMenuItem); + } + }, this::onError)); + } + @Override public void onError(@NonNull Throwable throwable) { if (!InputHelper.isEmpty(login)) { onWorkOffline(login); } + sendToView(ProfileOverviewMvp.View::onInvalidateMenuItem); super.onError(throwable); } @@ -36,6 +69,7 @@ class ProfileOverviewPresenter extends BasePresenter im makeRestCall(RestProvider.getUserService().getUser(login), userModel -> { onSendUserToView(userModel); + onCheckFollowStatus(login); if (userModel != null) { userModel.save(); } @@ -52,4 +86,8 @@ class ProfileOverviewPresenter extends BasePresenter im @Override public void onSendUserToView(@Nullable UserModel userModel) { sendToView(view -> view.onInitViews(userModel)); } + + @NonNull @Override public String getLogin() { + return login; + } } \ No newline at end of file diff --git a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewView.java b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewView.java index 31cb4c71..3dc02eb1 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewView.java +++ b/app/src/main/java/com/fastaccess/ui/modules/profile/overview/ProfileOverviewView.java @@ -6,9 +6,12 @@ import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.annotation.StringRes; import android.view.View; +import android.widget.Button; import com.fastaccess.R; +import com.fastaccess.data.dao.LoginModel; import com.fastaccess.data.dao.UserModel; +import com.fastaccess.helper.AnimHelper; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.Bundler; import com.fastaccess.helper.InputHelper; @@ -40,6 +43,8 @@ public class ProfileOverviewView extends BaseFragment implements UserPagerMvp.Presenter { - private boolean isSuccessResponse; - private boolean isFollowing; - - @Override public void onCheckFollowStatus(@NonNull String login) { - makeRestCall(RestProvider.getUserService().getFollowStatus(login), - booleanResponse -> { - isSuccessResponse = true; - isFollowing = booleanResponse.code() == 204; - sendToView(UserPagerMvp.View::onInvalidateMenuItem); - }); - } - - @Override public boolean isSuccessResponse() { - return isSuccessResponse; - } - - @Override public boolean isFollowing() { - return isFollowing; - } - - @Override public void onFollowMenuItemClicked(@NonNull String login) { - makeRestCall(!isFollowing ? RestProvider.getUserService().followUser(login) : RestProvider.getUserService().unfollowUser(login), - booleanResponse -> { - if (booleanResponse.code() == 204) { - isFollowing = !isFollowing; - sendToView(UserPagerMvp.View::onInvalidateMenuItem); - } - }); - } - - @Override public void onError(@NonNull Throwable throwable) { - sendToView(UserPagerMvp.View::onInvalidateMenuItem); - super.onError(throwable); - } -} +class UserPagerPresenter extends BasePresenter implements UserPagerMvp.Presenter {} diff --git a/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerView.java b/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerView.java index 4f8b0db5..3f608d09 100644 --- a/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerView.java +++ b/app/src/main/java/com/fastaccess/ui/modules/user/UserPagerView.java @@ -6,14 +6,9 @@ import android.os.Bundle; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import android.support.design.widget.TabLayout; -import android.support.v4.view.MenuItemCompat; -import android.view.Menu; -import android.view.MenuItem; -import android.widget.ProgressBar; import com.fastaccess.R; import com.fastaccess.data.dao.FragmentPagerAdapterModel; -import com.fastaccess.data.dao.LoginModel; import com.fastaccess.helper.BundleConstant; import com.fastaccess.helper.Bundler; import com.fastaccess.helper.InputHelper; @@ -75,16 +70,12 @@ public class UserPagerView extends BaseActivity + diff --git a/app/src/main/res/animator/minus_to_plus.xml b/app/src/main/res/animator/minus_to_plus.xml new file mode 100644 index 00000000..fd5c3483 --- /dev/null +++ b/app/src/main/res/animator/minus_to_plus.xml @@ -0,0 +1,9 @@ + + diff --git a/app/src/main/res/animator/plus_minus_rotate.xml b/app/src/main/res/animator/plus_minus_rotate.xml new file mode 100644 index 00000000..ffc8e43d --- /dev/null +++ b/app/src/main/res/animator/plus_minus_rotate.xml @@ -0,0 +1,8 @@ + + diff --git a/app/src/main/res/animator/plus_to_minus.xml b/app/src/main/res/animator/plus_to_minus.xml new file mode 100644 index 00000000..003ffd62 --- /dev/null +++ b/app/src/main/res/animator/plus_to_minus.xml @@ -0,0 +1,9 @@ + + diff --git a/app/src/main/res/animator/star_to_fill.xml b/app/src/main/res/animator/star_to_fill.xml new file mode 100644 index 00000000..18586e19 --- /dev/null +++ b/app/src/main/res/animator/star_to_fill.xml @@ -0,0 +1,9 @@ + + diff --git a/app/src/main/res/drawable/asl_follow.xml b/app/src/main/res/drawable/asl_follow.xml new file mode 100644 index 00000000..68eec21e --- /dev/null +++ b/app/src/main/res/drawable/asl_follow.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/avd_follow.xml b/app/src/main/res/drawable/avd_follow.xml new file mode 100644 index 00000000..1f87a213 --- /dev/null +++ b/app/src/main/res/drawable/avd_follow.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/avd_unfollow.xml b/app/src/main/res/drawable/avd_unfollow.xml new file mode 100644 index 00000000..57f36679 --- /dev/null +++ b/app/src/main/res/drawable/avd_unfollow.xml @@ -0,0 +1,14 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/ic_follow.xml b/app/src/main/res/drawable/ic_follow.xml new file mode 100644 index 00000000..299440a4 --- /dev/null +++ b/app/src/main/res/drawable/ic_follow.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_fork.xml b/app/src/main/res/drawable/ic_fork.xml index f7b41f1f..005368d1 100644 --- a/app/src/main/res/drawable/ic_fork.xml +++ b/app/src/main/res/drawable/ic_fork.xml @@ -1,4 +1,3 @@ - + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_star_filled.xml b/app/src/main/res/drawable/ic_star_filled.xml new file mode 100644 index 00000000..12edecb5 --- /dev/null +++ b/app/src/main/res/drawable/ic_star_filled.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_unfollow.xml b/app/src/main/res/drawable/ic_unfollow.xml new file mode 100644 index 00000000..41542021 --- /dev/null +++ b/app/src/main/res/drawable/ic_unfollow.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/app/src/main/res/layouts/row_layouts/layout/profile_overview_layout.xml b/app/src/main/res/layouts/row_layouts/layout/profile_overview_layout.xml index ad91e74d..1018cbe7 100644 --- a/app/src/main/res/layouts/row_layouts/layout/profile_overview_layout.xml +++ b/app/src/main/res/layouts/row_layouts/layout/profile_overview_layout.xml @@ -110,6 +110,22 @@ + + diff --git a/app/src/main/res/menu/follow_menu.xml b/app/src/main/res/menu/follow_menu.xml deleted file mode 100644 index a6ea7b4d..00000000 --- a/app/src/main/res/menu/follow_menu.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/paths.xml b/app/src/main/res/values/paths.xml new file mode 100644 index 00000000..5439943f --- /dev/null +++ b/app/src/main/res/values/paths.xml @@ -0,0 +1,6 @@ + + + M15,12C17.21,12 19,10.21 19,8C19,5.79 17.21,4 15,4C12.79,4 11,5.79 11,8C11,10.21 12.79,12 15,12L15,12ZM15,14C12.33,14 7,15.34 7,18L7,20L23,20L23,18C23,15.34 17.67,14 15,14L15,14Z + M6,7 L4,7 L4,10 L1,10 L1,12 L4,12 L4,15 L6,15 L6,12 L9,12 L9,10 L6,10 L6,7 Z + M6,10 L4,10 L4,10 L1,10 L1,12 L4,12 L4,12 L6,12 L6,12 L9,12 L9,10 L6,10 L6,10 Z +