diff options
author | Will Haldean Brown <haldean@google.com> | 2014-02-12 10:23:41 -0800 |
---|---|---|
committer | Will Haldean Brown <haldean@google.com> | 2014-03-04 09:26:15 -0800 |
commit | ca6234e084a71e0c968cff404620298bcd971fcc (patch) | |
tree | bd5c5a5ba959637f34af9d70e97b5b60def2eb70 /core/res | |
parent | a4bd2cbe509911729c9f185b045e54d7528d8836 (diff) | |
download | frameworks_base-ca6234e084a71e0c968cff404620298bcd971fcc.zip frameworks_base-ca6234e084a71e0c968cff404620298bcd971fcc.tar.gz frameworks_base-ca6234e084a71e0c968cff404620298bcd971fcc.tar.bz2 |
Add swipe-to-dismiss support to PhoneWindow.
This adds a new window feature -- FEATURE_SWIPE_TO_DISMISS -- and a
theme attribute to activate that feature. When the feature is
activated, a SwipeDismissLayout is inflated as the DecorView layout.
SwipeDismissLayout intercepts touch events and steals ones that are
large swipes to the right if its children don't. PhoneWindow registers
handlers that listen for these swipe events, translate the window when
necessary, and finish the activity at the end of the gesture.
Change-Id: I512e758f3c3ffd3b353dba3b911c0e80a88d6f5f
Diffstat (limited to 'core/res')
-rw-r--r-- | core/res/res/anim/swipe_window_enter.xml | 26 | ||||
-rw-r--r-- | core/res/res/anim/swipe_window_exit.xml | 26 | ||||
-rw-r--r-- | core/res/res/layout/screen_swipe_dismiss.xml | 27 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 5 | ||||
-rw-r--r-- | core/res/res/values/styles.xml | 8 | ||||
-rw-r--r-- | core/res/res/values/symbols.xml | 1 | ||||
-rw-r--r-- | core/res/res/values/themes_micro.xml | 20 |
7 files changed, 113 insertions, 0 deletions
diff --git a/core/res/res/anim/swipe_window_enter.xml b/core/res/res/anim/swipe_window_enter.xml new file mode 100644 index 0000000..e1617e2 --- /dev/null +++ b/core/res/res/anim/swipe_window_enter.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2007, 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="@interpolator/decelerate_quad" > + <alpha android:fromAlpha="0.0" android:toAlpha="1.0" + android:fillEnabled="true" android:fillBefore="true" + android:fillAfter="true" + android:duration="@android:integer/config_activityDefaultDur" /> +</set> diff --git a/core/res/res/anim/swipe_window_exit.xml b/core/res/res/anim/swipe_window_exit.xml new file mode 100644 index 0000000..ed0c5d3 --- /dev/null +++ b/core/res/res/anim/swipe_window_exit.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2007, 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="@interpolator/decelerate_quad" > + <translate android:fromXDelta="0%" android:toXDelta="100%" + android:fillEnabled="true" android:fillBefore="true" + android:fillAfter="true" + android:duration="400" /> +</set> diff --git a/core/res/res/layout/screen_swipe_dismiss.xml b/core/res/res/layout/screen_swipe_dismiss.xml new file mode 100644 index 0000000..90e970f --- /dev/null +++ b/core/res/res/layout/screen_swipe_dismiss.xml @@ -0,0 +1,27 @@ +<?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. +--> + +<!-- +This is a layout for a window whose resident activity is finished when swiped away. +--> + +<com.android.internal.widget.SwipeDismissLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@android:id/content" + android:fitsSystemWindows="true" + android:layout_width="match_parent" + android:layout_height="match_parent" + /> diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 42e3b50..24ebff3 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -447,6 +447,10 @@ to {@link android.view.WindowManager.LayoutParams#FLAG_TRANSLUCENT_NAVIGATION}. --> <attr name="windowTranslucentNavigation" format="boolean" /> + <!-- Flag to indicate that a window can be swiped away to be dismissed. + Corresponds to {@link android.view.Window.FEATURE_SWIPE_TO_DISMISS} --> + <attr name="windowSwipeToDismiss" format="boolean" /> + <!-- ============ --> <!-- Alert Dialog styles --> <!-- ============ --> @@ -1604,6 +1608,7 @@ <attr name="windowCloseOnTouchOutside" /> <attr name="windowTranslucentStatus" /> <attr name="windowTranslucentNavigation" /> + <attr name="windowSwipeToDismiss" /> <!-- The minimum width the window is allowed to be, along the major axis of the screen. That is, when in landscape. Can be either an absolute dimension or a fraction of the screen size in that diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index cb2fd6d..4d4feee 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -225,6 +225,14 @@ please see styles_device_defaults.xml. <item name="windowExitAnimation">@anim/fast_fade_out</item> </style> + <!-- Window animations for swipe-dismissable windows. {@hide} --> + <style name="Animation.SwipeDismiss"> + <item name="taskOpenEnterAnimation">@anim/swipe_window_enter</item> + <item name="taskOpenExitAnimation">@anim/swipe_window_exit</item> + <item name="taskCloseEnterAnimation">@anim/swipe_window_enter</item> + <item name="taskCloseExitAnimation">@anim/swipe_window_exit</item> + </style> + <!-- Status Bar Styles --> <style name="TextAppearance.StatusBar"> <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index ab3546c..c774451 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1374,6 +1374,7 @@ <java-symbol type="layout" name="screen_progress" /> <java-symbol type="layout" name="screen_simple" /> <java-symbol type="layout" name="screen_simple_overlay_action_mode" /> + <java-symbol type="layout" name="screen_swipe_dismiss" /> <java-symbol type="layout" name="screen_title" /> <java-symbol type="layout" name="screen_title_icons" /> <java-symbol type="string" name="system_ui_date_pattern" /> diff --git a/core/res/res/values/themes_micro.xml b/core/res/res/values/themes_micro.xml index b174d22..42f64fe 100644 --- a/core/res/res/values/themes_micro.xml +++ b/core/res/res/values/themes_micro.xml @@ -16,22 +16,42 @@ <resources> <style name="Theme.Micro" parent="Theme.Holo"> <item name="numberPickerStyle">@android:style/Widget.Micro.NumberPicker</item> + <item name="windowAnimationStyle">@android:style/Animation.SwipeDismiss</item> + <item name="windowIsFloating">false</item> + <item name="windowIsTranslucent">true</item> + <item name="windowSwipeToDismiss">true</item> </style> <style name="Theme.Micro.NoActionBar" parent="Theme.Holo.NoActionBar"> <item name="textViewStyle">@android:style/Widget.Micro.TextView</item> <item name="numberPickerStyle">@android:style/Widget.Micro.NumberPicker</item> + <item name="windowAnimationStyle">@android:style/Animation.SwipeDismiss</item> + <item name="windowIsFloating">false</item> + <item name="windowIsTranslucent">true</item> + <item name="windowSwipeToDismiss">true</item> </style> <style name="Theme.Micro.Light" parent="Theme.Holo.Light"> <item name="numberPickerStyle">@android:style/Widget.Micro.NumberPicker</item> + <item name="windowAnimationStyle">@android:style/Animation.SwipeDismiss</item> + <item name="windowIsFloating">false</item> + <item name="windowIsTranslucent">true</item> + <item name="windowSwipeToDismiss">true</item> </style> <style name="Theme.Micro.Light.NoActionBar" parent="Theme.Holo.Light.NoActionBar"> <item name="textViewStyle">@android:style/Widget.Micro.TextView</item> <item name="numberPickerStyle">@android:style/Widget.Micro.NumberPicker</item> + <item name="windowAnimationStyle">@android:style/Animation.SwipeDismiss</item> + <item name="windowIsFloating">false</item> + <item name="windowIsTranslucent">true</item> + <item name="windowSwipeToDismiss">true</item> </style> <style name="Theme.Micro.Light.DarkActionBar" parent="Theme.Holo.Light.DarkActionBar"> <item name="textViewStyle">@android:style/Widget.Micro.TextView</item> <item name="numberPickerStyle">@android:style/Widget.Micro.NumberPicker</item> + <item name="windowAnimationStyle">@android:style/Animation.SwipeDismiss</item> + <item name="windowIsFloating">false</item> + <item name="windowIsTranslucent">true</item> + <item name="windowSwipeToDismiss">true</item> </style> </resources> |