From 2cdaf57f101f54f80ea7d9e75845719a6cb0e0e3 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Thu, 14 Dec 2017 09:12:14 -0800 Subject: [PATCH 1/2] Make work footer stick to the bottom if there are only a few apps Bug: 70571983 Change-Id: I60ef59de0cfcbc8df24b270d0b6d2f6439ccad44 --- res/layout/work_tab_footer.xml | 103 +++++++++--------- .../views/WorkModeToggleContainer.java | 59 ++++++++++ 2 files changed, 109 insertions(+), 53 deletions(-) create mode 100644 src/com/android/launcher3/views/WorkModeToggleContainer.java diff --git a/res/layout/work_tab_footer.xml b/res/layout/work_tab_footer.xml index 48578d799a..64c95e3fc3 100644 --- a/res/layout/work_tab_footer.xml +++ b/res/layout/work_tab_footer.xml @@ -13,60 +13,57 @@ See the License for the specific language governing permissions and limitations under the License. --> - + - - - - - - - - - + android:layout_alignParentEnd="true" + android:theme="@style/WorkModeSwitchTheme"/> - + - - - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/src/com/android/launcher3/views/WorkModeToggleContainer.java b/src/com/android/launcher3/views/WorkModeToggleContainer.java new file mode 100644 index 0000000000..c1b5ddd256 --- /dev/null +++ b/src/com/android/launcher3/views/WorkModeToggleContainer.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2017 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. + */ +package com.android.launcher3.views; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.widget.RelativeLayout; + +/** + * Container to show work mode toggle in all-apps + */ +public class WorkModeToggleContainer extends RelativeLayout { + + public WorkModeToggleContainer(Context context) { + super(context); + } + + public WorkModeToggleContainer(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public WorkModeToggleContainer(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + updateTranslation(); + } + + @Override + public void offsetTopAndBottom(int offset) { + super.offsetTopAndBottom(offset); + updateTranslation(); + } + + private void updateTranslation() { + if (getParent() instanceof View) { + View parent = (View) getParent(); + int availableBot = parent.getHeight() - parent.getPaddingBottom(); + setTranslationY(Math.max(0, availableBot - getBottom())); + } + } +} From 2bfa4d469a271c9e43a9e4c55a8da3c0a203acb8 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Fri, 15 Dec 2017 11:38:11 +0000 Subject: [PATCH 2/2] Make work footer stick to the bottom if there are only a few apps #2 1. Move the work footer divider into the container, so it is translated with the rest of the footer. 2. Fixed the scrollbar issue in work tab by putting the footer height in AllAppsRecyclerView 3. We planned to drop the company name, and decided to use "Managed by your organisation". 4. Rename WorkModeToggleContainer to WorkFooterContainer as we are using work footer in else where. BUG: 70571983 Change-Id: I218fe7d9970780a1a457ee450f1a32e7a46d9766 --- res/layout/work_tab_footer.xml | 19 +++++++++++++++---- res/values/strings.xml | 2 ++ .../launcher3/allapps/AllAppsGridAdapter.java | 4 ---- .../allapps/AllAppsRecyclerView.java | 2 ++ .../allapps/AlphabeticalAppsList.java | 1 - ...ontainer.java => WorkFooterContainer.java} | 10 +++++----- 6 files changed, 24 insertions(+), 14 deletions(-) rename src/com/android/launcher3/views/{WorkModeToggleContainer.java => WorkFooterContainer.java} (82%) diff --git a/res/layout/work_tab_footer.xml b/res/layout/work_tab_footer.xml index 64c95e3fc3..2606b87a10 100644 --- a/res/layout/work_tab_footer.xml +++ b/res/layout/work_tab_footer.xml @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + + - - \ No newline at end of file + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index eca64c852b..d77065c11f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -330,5 +330,7 @@ Find work apps here Each work app has an orange badge, which means it\'s kept secure by your organization. Work apps can be moved to your Home Screen for easier access. + + Managed by your organisation diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index da4d9f0cc2..246f7be10e 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -381,10 +381,6 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter