mirror of
https://github.com/Hamza417/Inure.git
synced 2026-03-13 10:19:43 +08:00
add: base for predictive back
This commit is contained in:
@@ -62,7 +62,7 @@
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:enableOnBackInvokedCallback="false"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
||||
@@ -3,6 +3,7 @@ package app.simple.inure.activities.app
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.content.res.Configuration
|
||||
import android.net.wifi.hotspot2.pps.HomeSp
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
@@ -242,11 +243,11 @@ class MainActivity : BaseActivity() {
|
||||
if (isNewIntent.invert()) { // Maybe the app was opened from launcher, need more checks?
|
||||
if (AppUtils.isDebug()) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.app_container, SplashScreen.newInstance(false), SplashScreen.TAG)
|
||||
.replace(R.id.app_container, Home.newInstance(), SplashScreen.TAG)
|
||||
.commit()
|
||||
} else {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.app_container, SplashScreen.newInstance(false), SplashScreen.TAG)
|
||||
.replace(R.id.app_container, Home.newInstance(), SplashScreen.TAG)
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package app.simple.inure.decorations.transitions;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.transition.TransitionValues;
|
||||
import androidx.transition.Visibility;
|
||||
|
||||
public class SeekableSharedAxisZTransition extends Visibility {
|
||||
public static final int DECELERATE_FACTOR = 3;
|
||||
private static final float SCALE_IN_FROM = 0.9f;
|
||||
private static final float SCALE_OUT_TO = 1.1f;
|
||||
private static final long DEFAULT_DURATION = 500L;
|
||||
private final boolean forward;
|
||||
|
||||
public SeekableSharedAxisZTransition(boolean forward) {
|
||||
this.forward = forward;
|
||||
setDuration(DEFAULT_DURATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSeekingSupported() {
|
||||
// Important for predictive back
|
||||
return true;
|
||||
}
|
||||
|
||||
private Animator createAnimator(final View view, final float startScale, final float endScale,
|
||||
final float startAlpha, final float endAlpha) {
|
||||
if (view instanceof ImageView) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f);
|
||||
animator.setDuration(DEFAULT_DURATION);
|
||||
animator.setInterpolator(new DecelerateInterpolator(DECELERATE_FACTOR));
|
||||
animator.addUpdateListener(animation -> {
|
||||
float progress = (float) animation.getAnimatedValue();
|
||||
float scale = startScale + (endScale - startScale) * progress;
|
||||
float alpha = startAlpha + (endAlpha - startAlpha) * progress;
|
||||
view.setScaleX(scale);
|
||||
view.setScaleY(scale);
|
||||
view.setAlpha(alpha);
|
||||
});
|
||||
|
||||
return animator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator onAppear(@NonNull ViewGroup sceneRoot,
|
||||
@NonNull View view,
|
||||
TransitionValues startValues,
|
||||
TransitionValues endValues) {
|
||||
// Entering: scale from behind, fade in
|
||||
float startScale = forward ? SCALE_IN_FROM : SCALE_OUT_TO;
|
||||
float endScale = 1f;
|
||||
return createAnimator(view, startScale, endScale, 0f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view,
|
||||
TransitionValues startValues, TransitionValues endValues) {
|
||||
// Exiting: scale out, fade out
|
||||
float endScale = forward ? SCALE_OUT_TO : SCALE_IN_FROM;
|
||||
float startScale = 1f;
|
||||
return createAnimator(view, startScale, endScale, 1f, 0f);
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import app.simple.inure.R
|
||||
import app.simple.inure.apk.utils.PackageUtils
|
||||
import app.simple.inure.constants.BundleConstants
|
||||
import app.simple.inure.decorations.transitions.DetailsTransitionArc
|
||||
import app.simple.inure.decorations.transitions.SeekableSharedAxisZTransition
|
||||
import app.simple.inure.decorations.views.FloatingMenuRecyclerView
|
||||
import app.simple.inure.dialogs.app.FullVersion.Companion.showFullVersion
|
||||
import app.simple.inure.dialogs.app.Sure.Companion.newSureInstance
|
||||
@@ -293,10 +294,10 @@ abstract class ScopedFragment : Fragment(), SharedPreferences.OnSharedPreference
|
||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Y, false)
|
||||
}
|
||||
PopupTransitionType.SHARED_AXIS_Z -> {
|
||||
enterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true)
|
||||
exitTransition = MaterialSharedAxis(MaterialSharedAxis.Z, true)
|
||||
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||
returnTransition = MaterialSharedAxis(MaterialSharedAxis.Z, false)
|
||||
enterTransition = SeekableSharedAxisZTransition(true)
|
||||
exitTransition = SeekableSharedAxisZTransition(true)
|
||||
reenterTransition = SeekableSharedAxisZTransition(false)
|
||||
returnTransition = SeekableSharedAxisZTransition(false)
|
||||
}
|
||||
PopupTransitionType.THROUGH -> {
|
||||
exitTransition = MaterialFadeThrough()
|
||||
@@ -622,7 +623,7 @@ abstract class ScopedFragment : Fragment(), SharedPreferences.OnSharedPreference
|
||||
|
||||
view.scaleX = 1F - (0.1F * interpolatedProgress)
|
||||
view.scaleY = 1F - (0.1F * interpolatedProgress)
|
||||
// view.alpha = 1F - (0.5F * interpolatedProgress)
|
||||
view.alpha = 1F - (0.5F * interpolatedProgress)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
|
||||
@@ -748,7 +749,7 @@ abstract class ScopedFragment : Fragment(), SharedPreferences.OnSharedPreference
|
||||
val transaction = requireActivity().supportFragmentManager.beginTransaction().apply {
|
||||
setReorderingAllowed(true)
|
||||
addSharedElement(icon, icon.transitionName)
|
||||
replace(R.id.app_container, fragment, tag)
|
||||
add (R.id.app_container, fragment, tag)
|
||||
if (tag.isNotNull()) {
|
||||
addToBackStack(tag)
|
||||
}
|
||||
@@ -759,7 +760,7 @@ abstract class ScopedFragment : Fragment(), SharedPreferences.OnSharedPreference
|
||||
val transaction = requireActivity().supportFragmentManager.beginTransaction().apply {
|
||||
setReorderingAllowed(true)
|
||||
addSharedElement(icon, icon.transitionName)
|
||||
replace(R.id.app_container, fragment, tag)
|
||||
add(R.id.app_container, fragment, tag)
|
||||
if (tag.isNotNull()) {
|
||||
addToBackStack(tag)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user