Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8871134d authored by Yi-Ling Chuang's avatar Yi-Ling Chuang
Browse files

Simplify the transition logic.

- Only override startAcitivtyForResult() as other methods will also fall
to that one.

Bug: 187542491
Test: rebuild and navigate through pages
Change-Id: I2d5cf0c3deaa858d44c4330600e88b0f33ce0594
parent f6d08457
Loading
Loading
Loading
Loading
+7 −69
Original line number Diff line number Diff line
@@ -163,85 +163,23 @@ public class SettingsBaseActivity extends FragmentActivity {
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void startActivity(Intent intent) {
        if (!Utils.isPageTransitionEnabled(this)) {
            super.startActivity(intent);
            return;
        }

        final int transitionType = getTransitionType(intent);
        if (transitionType == TransitionType.TRANSITION_SLIDE) {
            super.startActivity(intent, null);
            overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
            return;
        } else if (transitionType == TransitionType.TRANSITION_NONE) {
            super.startActivity(intent, null);
            return;
        } else if (transitionType == TransitionType.TRANSITION_FADE) {
            super.startActivity(intent, null);
            overridePendingTransition(android.R.anim.fade_in, R.anim.sud_stay);
            return;
        }
        super.startActivity(intent, createActivityOptionsBundleForTransition(null));
    }

    @Override
    public void startActivity(Intent intent, @androidx.annotation.Nullable Bundle options) {
        final int transitionType = getTransitionType(intent);
        if (!Utils.isPageTransitionEnabled(this) ||
                transitionType == TransitionType.TRANSITION_NONE) {
            super.startActivity(intent, options);
            return;
        }

        if (transitionType == TransitionType.TRANSITION_SLIDE) {
            super.startActivity(intent, options);
            overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
            return;
        }
        super.startActivity(intent, createActivityOptionsBundleForTransition(options));
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        final int transitionType = getTransitionType(intent);
        // startActivity() will eventually calls startActivityForResult() with requestCode -1.
        // Adding this condition to avoid multiple calls.
        if (!Utils.isPageTransitionEnabled(this) || requestCode == DEFAULT_REQUEST
                || transitionType == TransitionType.TRANSITION_NONE) {
            super.startActivityForResult(intent, requestCode);
            return;
        }

        if (transitionType == TransitionType.TRANSITION_SLIDE) {
            super.startActivityForResult(intent, requestCode, null);
            overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
            return;
        }

        super.startActivityForResult(intent, requestCode,
                createActivityOptionsBundleForTransition(null));
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode,
            @androidx.annotation.Nullable Bundle options) {
        final int transitionType = getTransitionType(intent);
        if (!Utils.isPageTransitionEnabled(this) || requestCode == DEFAULT_REQUEST
                || transitionType == TransitionType.TRANSITION_NONE) {
            super.startActivityForResult(intent, requestCode, options);
        if (Utils.isPageTransitionEnabled(this) &&
                transitionType == TransitionType.TRANSITION_SHARED_AXIS) {
            super.startActivityForResult(intent, requestCode,
                    createActivityOptionsBundleForTransition(options));
            return;
        }

        if (transitionType == TransitionType.TRANSITION_SLIDE) {
        super.startActivityForResult(intent, requestCode, options);
        if (transitionType == TransitionType.TRANSITION_SLIDE) {
            overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
            return;
        } else if (transitionType == TransitionType.TRANSITION_FADE) {
            overridePendingTransition(android.R.anim.fade_in, R.anim.sud_stay);
        }

        super.startActivityForResult(intent, requestCode,
                createActivityOptionsBundleForTransition(options));
    }

    @Override