Browse Source

Animations for activity transitions

master
Anthony Restaino 9 years ago
parent
commit
1896fa6151
  1. 11
      app/src/main/java/acr/browser/lightning/activity/AppCompatPreferenceActivity.java
  2. 4
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  3. 16
      app/src/main/res/anim/fade_in_scale.xml
  4. 16
      app/src/main/res/anim/fade_out_scale.xml
  5. 12
      app/src/main/res/anim/slide_down_out.xml
  6. 12
      app/src/main/res/anim/slide_in_from_right.xml
  7. 12
      app/src/main/res/anim/slide_out_to_right.xml
  8. 12
      app/src/main/res/anim/slide_up_in.xml

11
app/src/main/java/acr/browser/lightning/activity/AppCompatPreferenceActivity.java

@ -13,6 +13,8 @@ import android.view.MenuInflater; @@ -13,6 +13,8 @@ import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import acr.browser.lightning.R;
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
@ -26,6 +28,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { @@ -26,6 +28,7 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
overridePendingTransition(R.anim.slide_in_from_right, R.anim.fade_out_scale);
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
@ -89,6 +92,14 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity { @@ -89,6 +92,14 @@ public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
getDelegate().onConfigurationChanged(newConfig);
}
@Override
protected void onPause() {
super.onPause();
if (isFinishing()) {
overridePendingTransition(R.anim.fade_in_scale, R.anim.slide_out_to_right);
}
}
@Override
protected void onStop() {
super.onStop();

4
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -782,6 +782,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -782,6 +782,7 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
return true;
case R.id.action_incognito:
startActivity(new Intent(this, IncognitoActivity.class));
overridePendingTransition(R.anim.slide_up_in, R.anim.fade_out_scale);
return true;
case R.id.action_share:
if (mCurrentView != null && !mCurrentView.getUrl().startsWith(Constants.FILE)) {
@ -1444,6 +1445,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements @@ -1444,6 +1445,9 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
if (isIncognito() && isFinishing()) {
overridePendingTransition(R.anim.fade_in_scale, R.anim.slide_down_out);
}
}
void saveOpenTabs() {

16
app/src/main/res/anim/fade_in_scale.xml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="0.85"
android:fromYScale="0.85"
android:interpolator="@android:interpolator/decelerate_cubic"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="1.0"
android:toYScale="1.0" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>

16
app/src/main/res/anim/fade_out_scale.xml

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:duration="@android:integer/config_mediumAnimTime"
android:fromXScale="1.0"
android:fromYScale="1.0"
android:interpolator="@android:interpolator/decelerate_cubic"
android:pivotX="50%p"
android:pivotY="50%p"
android:toXScale="0.85"
android:toYScale="0.85" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>

12
app/src/main/res/anim/slide_down_out.xml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="0%p"
android:interpolator="@android:interpolator/accelerate_cubic"
android:toYDelta="100%p" />
<alpha
android:duration="@android:integer/config_mediumAnimTime"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>

12
app/src/main/res/anim/slide_in_from_right.xml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="100%p"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toXDelta="0%p" />
<!--<alpha-->
<!--android:duration="@android:integer/config_mediumAnimTime"-->
<!--android:fromAlpha="0.0"-->
<!--android:toAlpha="1.0" />-->
</set>

12
app/src/main/res/anim/slide_out_to_right.xml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromXDelta="0%p"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toXDelta="100%p" />
<!--<alpha-->
<!--android:duration="@android:integer/config_mediumAnimTime"-->
<!--android:fromAlpha="0.0"-->
<!--android:toAlpha="1.0" />-->
</set>

12
app/src/main/res/anim/slide_up_in.xml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="@android:integer/config_mediumAnimTime"
android:fromYDelta="100%p"
android:interpolator="@android:interpolator/decelerate_cubic"
android:toYDelta="0%p" />
<!--<alpha-->
<!--android:duration="@android:integer/config_mediumAnimTime"-->
<!--android:fromAlpha="0.5"-->
<!--android:toAlpha="1.0" />-->
</set>
Loading…
Cancel
Save