diff options
-rw-r--r-- | res/anim/floating_action_button_elevation.xml | 16 | ||||
-rw-r--r-- | res/drawable/floating_action_button.xml | 3 | ||||
-rw-r--r-- | res/layout/fab.xml | 23 | ||||
-rw-r--r-- | res/layout/profile_tabs.xml | 20 | ||||
-rwxr-xr-x | res/values/dimens.xml | 7 | ||||
-rw-r--r-- | res/values/styles.xml | 19 | ||||
-rw-r--r-- | src/com/android/settings/profiles/ProfilesSettings.java | 4 |
7 files changed, 72 insertions, 20 deletions
diff --git a/res/anim/floating_action_button_elevation.xml b/res/anim/floating_action_button_elevation.xml new file mode 100644 index 0000000..8b33d89 --- /dev/null +++ b/res/anim/floating_action_button_elevation.xml @@ -0,0 +1,16 @@ +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_pressed="true"> + <objectAnimator + android:propertyName="translationZ" + android:duration="@android:integer/config_shortAnimTime" + android:valueTo="@dimen/fab_elevation_pressed" + android:valueType="floatType"/> + </item> + <item> + <objectAnimator + android:propertyName="translationZ" + android:duration="@android:integer/config_shortAnimTime" + android:valueTo="0dp" + android:valueType="floatType"/> + </item> +</selector> diff --git a/res/drawable/floating_action_button.xml b/res/drawable/floating_action_button.xml index d550190..770d8ba 100644 --- a/res/drawable/floating_action_button.xml +++ b/res/drawable/floating_action_button.xml @@ -22,4 +22,5 @@ <solid android:color="@android:color/white" /> </shape> </item> -</ripple>
\ No newline at end of file + <item android:drawable="@drawable/fab_accent"/> +</ripple> diff --git a/res/layout/fab.xml b/res/layout/fab.xml new file mode 100644 index 0000000..9c41f3e --- /dev/null +++ b/res/layout/fab.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 The CyanogenMod 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. +--> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/floating_action_button" + style="@style/floating_action_button"> + <ImageView + style="@style/floating_action_button_image" + android:src="@drawable/ic_menu_add_white"/> +</FrameLayout>
\ No newline at end of file diff --git a/res/layout/profile_tabs.xml b/res/layout/profile_tabs.xml index b29c1ae..9ae3452 100644 --- a/res/layout/profile_tabs.xml +++ b/res/layout/profile_tabs.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2013 The CyanogenMod Project +<!-- + Copyright (C) 2014 The CyanogenMod Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -27,22 +28,7 @@ </android.support.v4.view.ViewPager> - <FrameLayout - android:id="@+id/floating_action_button_container" - android:background="@drawable/fab_accent" - android:layout_alignParentRight="true" - android:layout_alignParentBottom="true" - android:layout_margin="16dp" - android:elevation="4dp" - android:layout_height="wrap_content" - android:layout_width="wrap_content"> - <ImageButton - android:id="@+id/floating_action_button" - android:layout_width="56dp" - android:layout_height="56dp" - android:background="@drawable/floating_action_button" - android:src="@drawable/ic_menu_add"/> - </FrameLayout> + <include layout="@layout/fab" /> <TextView android:id="@+id/empty" diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 9a2786c..d921b9b 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -264,4 +264,11 @@ <dimen name="shortcut_size">40dp</dimen> <dimen name="badge_size">10dp</dimen> + + <!-- FAB Dimensions --> + <dimen name="fab_size">56dp</dimen> + <dimen name="fab_margin">16dp</dimen> + <dimen name="fab_icon_size">24dp</dimen> + <dimen name="fab_elevation_normal">8dp</dimen> + <dimen name="fab_elevation_pressed">6dp</dimen> </resources> diff --git a/res/values/styles.xml b/res/values/styles.xml index d6fd326..19b0f7d 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -370,4 +370,23 @@ <item name="android:layout_width">match_parent</item> <item name="android:layout_height">1dp</item> </style> + + <style name="floating_action_button"> + <item name="android:layout_width">@dimen/fab_size</item> + <item name="android:layout_height">@dimen/fab_size</item> + <item name="android:layout_margin">@dimen/fab_margin</item> + <item name="android:background">@drawable/floating_action_button</item> + <item name="android:stateListAnimator">@anim/floating_action_button_elevation</item> + <item name="android:elevation">@dimen/fab_elevation_normal</item> + <item name="android:layout_alignParentBottom">true</item> + <item name="android:layout_alignParentRight">true</item> + <item name="android:layout_gravity">bottom|right</item> + </style> + + <style name="floating_action_button_image"> + <item name="android:layout_width">@dimen/fab_icon_size</item> + <item name="android:layout_height">@dimen/fab_icon_size</item> + <item name="android:layout_gravity">center</item> + <item name="android:background">@android:color/transparent</item> + </style> </resources> diff --git a/src/com/android/settings/profiles/ProfilesSettings.java b/src/com/android/settings/profiles/ProfilesSettings.java index 7f259b2..92a9610 100644 --- a/src/com/android/settings/profiles/ProfilesSettings.java +++ b/src/com/android/settings/profiles/ProfilesSettings.java @@ -67,7 +67,7 @@ public class ProfilesSettings extends SettingsPreferenceFragment { private ViewPager mViewPager; private TextView mEmptyText; private ProfilesPagerAdapter mAdapter; - private ImageView mAddProfileFab; + private View mAddProfileFab; private boolean mEnabled; ViewGroup mContainer; @@ -99,7 +99,7 @@ public class ProfilesSettings extends SettingsPreferenceFragment { View view = inflater.inflate(R.layout.profile_tabs, container, false); mViewPager = (ViewPager) view.findViewById(R.id.pager); mEmptyText = (TextView) view.findViewById(R.id.empty); - mAddProfileFab = (ImageView) view.findViewById(R.id.floating_action_button); + mAddProfileFab = view.findViewById(R.id.floating_action_button); mAddProfileFab.setOnClickListener( new View.OnClickListener() { @Override |