Simplified transition animations

This commit is contained in:
M66B 2019-01-31 18:08:17 +00:00
parent 84fbf98e89
commit 96b7a8340e
4 changed files with 17 additions and 41 deletions

View File

@ -44,7 +44,6 @@ import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
@ -1096,15 +1095,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
args.putBoolean("pane", true); args.putBoolean("pane", true);
} }
TypedValue enter = new TypedValue();
TypedValue exit = new TypedValue();
getTheme().resolveAttribute(android.R.attr.activityOpenEnterAnimation, enter, false);
getTheme().resolveAttribute(android.R.attr.activityOpenExitAnimation, exit, false);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(
enter.resourceId, exit.resourceId,
android.R.anim.fade_out, android.R.anim.fade_out);
fragmentTransaction.replace(pane, fragment).addToBackStack("thread"); fragmentTransaction.replace(pane, fragment).addToBackStack("thread");
fragmentTransaction.commit(); fragmentTransaction.commit();
} }

View File

@ -48,6 +48,7 @@ import android.view.SubMenu;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.animation.Animation; import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.TextView; import android.widget.TextView;
@ -129,7 +130,6 @@ public class FragmentMessages extends FragmentBase {
private boolean connected; private boolean connected;
private boolean searching = false; private boolean searching = false;
private AdapterMessage adapter; private AdapterMessage adapter;
private boolean animate = true;
private AdapterMessage.ViewType viewType; private AdapterMessage.ViewType viewType;
private SelectionTracker<Long> selectionTracker = null; private SelectionTracker<Long> selectionTracker = null;
@ -2166,6 +2166,8 @@ public class FragmentMessages extends FragmentBase {
getFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE); getFragmentManager().popBackStack("thread", FragmentManager.POP_BACK_STACK_INCLUSIVE);
getArguments().putBoolean("fade", true);
Bundle nargs = new Bundle(); Bundle nargs = new Bundle();
nargs.putLong("account", message.account); nargs.putLong("account", message.account);
nargs.putString("thread", message.thread); nargs.putString("thread", message.thread);
@ -2173,16 +2175,13 @@ public class FragmentMessages extends FragmentBase {
nargs.putBoolean("pane", pane); nargs.putBoolean("pane", pane);
nargs.putLong("primary", primary); nargs.putLong("primary", primary);
nargs.putBoolean("connected", connected); nargs.putBoolean("connected", connected);
nargs.putBoolean("left", left);
FragmentMessages fragment = new FragmentMessages(); FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(nargs); fragment.setArguments(nargs);
int res = (pane ? R.id.content_pane : R.id.content_frame); int res = (pane ? R.id.content_pane : R.id.content_frame);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(
left ? R.anim.enter_from_left : R.anim.enter_from_right,
left ? R.anim.exit_to_right : R.anim.exit_to_left,
android.R.anim.fade_out, android.R.anim.fade_out);
fragmentTransaction.replace(res, fragment).addToBackStack("thread"); fragmentTransaction.replace(res, fragment).addToBackStack("thread");
fragmentTransaction.commit(); fragmentTransaction.commit();
} }
@ -2397,20 +2396,26 @@ public class FragmentMessages extends FragmentBase {
return true; return true;
} }
animate = false;
return false; return false;
} }
}; };
@Override @Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) { public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
if (!animate) { Bundle args = getArguments();
Animation a = new Animation() { if (viewType == AdapterMessage.ViewType.THREAD && args != null) {
}; if (enter) {
a.setDuration(0); Boolean left = (Boolean) args.get("left");
return a; if (left != null)
return AnimationUtils.loadAnimation(getContext(), left ? R.anim.enter_from_left : R.anim.enter_from_right);
} else {
if (args.getBoolean("fade")) {
args.remove("fade");
return AnimationUtils.loadAnimation(getContext(), android.R.anim.fade_out);
}
}
} }
return super.onCreateAnimation(transit, enter, nextAnim); return super.onCreateAnimation(transit, enter, nextAnim);
} }

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="-100%"
android:toYDelta="0%" />
</set>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="@android:integer/config_longAnimTime"
android:fromXDelta="0%"
android:fromYDelta="0%"
android:toXDelta="100%"
android:toYDelta="0%" />
</set>