Skip to content

Commit

Permalink
Add transitions and animations.
Browse files Browse the repository at this point in the history
Bug: 19300912
Change-Id: Idfb1e11f3e4d403c8412f99f9bc62860d7771ea9
  • Loading branch information
mangini committed Mar 10, 2015
1 parent 305cf0b commit 4ea3ebe
Show file tree
Hide file tree
Showing 13 changed files with 216 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/UAmpAppTheme" >

<meta-data
android:name="com.google.android.gms.car.application"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,14 @@ public void run() {
private DrawerLayout.DrawerListener mDrawerListener = new DrawerLayout.DrawerListener() {
@Override
public void onDrawerClosed(View drawerView) {
getSupportActionBar().setTitle(getTitle());
if (mDrawerToggle != null) mDrawerToggle.onDrawerClosed(drawerView);
if (mItemToOpenWhenDrawerCloses >= 0) {
int position = mItemToOpenWhenDrawerCloses;
mItemToOpenWhenDrawerCloses = -1;
int position = mItemToOpenWhenDrawerCloses;
if (position >= 0) {
Bundle extras = ActivityOptions.makeCustomAnimation(
ActionBarCastActivity.this, 0, 0).toBundle();
ActionBarCastActivity.this, R.anim.fade_in, R.anim.fade_out).toBundle();

Class activityClass = mDrawerMenuContents.getActivity(position);
startActivity(new Intent(ActionBarCastActivity.this,activityClass), extras);
startActivity(new Intent(ActionBarCastActivity.this, activityClass), extras);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ protected void showPlaybackControls() {
PlaybackControlsFragment controlsFragment = (PlaybackControlsFragment)
getFragmentManager().findFragmentById(R.id.controls);
if (controlsFragment == null && NetworkHelper.isOnline(this)) {
PlaybackControlsFragment fragment = new PlaybackControlsFragment();
controlsFragment = new PlaybackControlsFragment();
getFragmentManager().beginTransaction()
.replace(R.id.controls, fragment)
.setCustomAnimations(
R.animator.slide_in_from_bottom, R.animator.slide_out_to_bottom,
R.animator.slide_in_from_bottom, R.animator.slide_out_to_bottom)
.add(R.id.controls, controlsFragment)
.commit();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ private void navigateToBrowser(String mediaId) {
fragment = new MediaBrowserFragment();
fragment.setMediaId(mediaId);
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.setCustomAnimations(
R.animator.slide_in_from_right, R.animator.slide_out_to_left,
R.animator.slide_in_from_left, R.animator.slide_out_to_right);
transaction.replace(R.id.container, fragment);
// If this is not the top level media (root), we add it to the fragment back stack,
// so that actionbar toggle and Back will work appropriately:
Expand Down
22 changes: 22 additions & 0 deletions mobile/src/main/res/anim/fade_in.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/decelerate_quad"
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="@android:integer/config_shortAnimTime"
/>
22 changes: 22 additions & 0 deletions mobile/src/main/res/anim/fade_out.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/accelerate_quad"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="@android:integer/config_shortAnimTime"
/>
24 changes: 24 additions & 0 deletions mobile/src/main/res/animator/slide_in_from_bottom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/fast_out_slow_in">
<objectAnimator
android:propertyName="y"
android:valueType="floatType"
android:valueFrom="2000"
android:valueTo="0"/>
</set>
24 changes: 24 additions & 0 deletions mobile/src/main/res/animator/slide_in_from_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/fast_out_slow_in">
<objectAnimator
android:propertyName="x"
android:valueType="floatType"
android:valueFrom="-2000"
android:valueTo="0"/>
</set>
24 changes: 24 additions & 0 deletions mobile/src/main/res/animator/slide_in_from_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/fast_out_slow_in">
<objectAnimator
android:propertyName="x"
android:valueType="floatType"
android:valueFrom="2000"
android:valueTo="0"/>
</set>
24 changes: 24 additions & 0 deletions mobile/src/main/res/animator/slide_out_to_bottom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/fast_out_slow_in">
<objectAnimator
android:propertyName="y"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="2000"/>
</set>
30 changes: 30 additions & 0 deletions mobile/src/main/res/animator/slide_out_to_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:ordering="together">
<objectAnimator
android:propertyName="x"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="-2000"/>
<objectAnimator
android:propertyName="alpha"
android:valueType="floatType"
android:valueFrom="1"
android:valueTo="0"/>
</set>
30 changes: 30 additions & 0 deletions mobile/src/main/res/animator/slide_out_to_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:ordering="together">
<objectAnimator
android:propertyName="x"
android:valueType="floatType"
android:valueFrom="0"
android:valueTo="2000"/>
<objectAnimator
android:propertyName="alpha"
android:valueType="floatType"
android:valueFrom="1"
android:valueTo="0"/>
</set>
5 changes: 3 additions & 2 deletions mobile/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
limitations under the License.
-->
<resources>
<style name="UAmpAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowContentTransitions">true</item>

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- colorPrimary is used for:
- Phone: Action bar (App bar)
- Auto: Notification icon and bottom facet bar icons and overflow actions
Expand All @@ -36,4 +37,4 @@
<item name="colorAccent">#ffff5722</item>
</style>

</resources>
</resources>

0 comments on commit 4ea3ebe

Please sign in to comment.