Merge "Add work toggle to work apps paused message" into sc-dev
This commit is contained in:
commit
29dba38119
|
@ -16,30 +16,38 @@
|
|||
<com.android.launcher3.allapps.WorkEduCard xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/work_edu_card_margin"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/work_card"
|
||||
android:gravity="center">
|
||||
|
||||
<TextView
|
||||
style="@style/PrimaryHeadline"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:id="@+id/work_apps_paused_title"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/work_profile_edu_work_apps"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp" />
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/work_edu_card_margin"
|
||||
android:background="@drawable/work_card"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:id="@+id/wrapper">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/action_btn"
|
||||
android:textColor="?attr/workProfileOverlayTextColor"
|
||||
android:text="@string/work_profile_edu_accept"
|
||||
android:textAlignment="center"
|
||||
android:background="@drawable/work_card_btn"
|
||||
android:textSize="14sp" />
|
||||
<TextView
|
||||
style="@style/PrimaryHeadline"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:id="@+id/work_apps_paused_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/work_profile_edu_work_apps"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/action_btn"
|
||||
android:textColor="?attr/workProfileOverlayTextColor"
|
||||
android:text="@string/work_profile_edu_accept"
|
||||
android:textAlignment="center"
|
||||
android:background="@drawable/work_card_btn"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
</com.android.launcher3.allapps.WorkEduCard>
|
|
@ -12,11 +12,10 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<com.android.launcher3.allapps.WorkPausedCard xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/allAppsScrimColor"
|
||||
android:padding="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/work_edu_card_margin"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
|
||||
|
@ -39,5 +38,16 @@
|
|||
android:textColor="?attr/workProfileOverlayTextColor"
|
||||
android:text="@string/work_apps_paused_body"
|
||||
android:textAlignment="center"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/enable_work_apps"
|
||||
android:textColor="?attr/workProfileOverlayTextColor"
|
||||
android:text="@string/work_apps_enable_btn_text"
|
||||
android:textAlignment="center"
|
||||
android:background="@drawable/work_card_btn"
|
||||
android:textSize="14sp" />
|
||||
</com.android.launcher3.allapps.WorkPausedCard>
|
|
@ -94,7 +94,7 @@
|
|||
<dimen name="all_apps_background_canvas_height">475dp</dimen>
|
||||
<dimen name="all_apps_header_pill_height">48dp</dimen>
|
||||
<dimen name="all_apps_header_pill_corner_radius">18dp</dimen>
|
||||
<dimen name="all_apps_header_pills_width">320dp</dimen>
|
||||
<dimen name="all_apps_header_pills_width">348dp</dimen>
|
||||
<dimen name="all_apps_header_tab_height">48dp</dimen>
|
||||
<dimen name="all_apps_tabs_indicator_height">2dp</dimen>
|
||||
<dimen name="all_apps_header_top_padding">36dp</dimen>
|
||||
|
|
|
@ -23,7 +23,6 @@ import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_
|
|||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -494,15 +493,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
View overlay = mAH[AdapterHolder.WORK].getOverlayView();
|
||||
int v = newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE ? GONE : VISIBLE;
|
||||
overlay.findViewById(R.id.work_apps_paused_title).setVisibility(v);
|
||||
overlay.findViewById(R.id.work_apps_paused_content).setVisibility(v);
|
||||
}
|
||||
|
||||
private void replaceRVContainer(boolean showTabs) {
|
||||
for (int i = 0; i < mAH.length; i++) {
|
||||
if (mAH[i].recyclerView != null) {
|
||||
|
@ -544,9 +534,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
|||
&& mAllAppsStore.hasModelFlag(
|
||||
FLAG_HAS_SHORTCUT_PERMISSION | FLAG_QUIET_MODE_CHANGE_PERMISSION));
|
||||
}
|
||||
if (mSearchUiManager != null && mSearchUiManager.getEditText() != null) {
|
||||
mSearchUiManager.getEditText().hideKeyboard();
|
||||
}
|
||||
}
|
||||
|
||||
// Used by tests only
|
||||
|
@ -704,7 +691,9 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
|||
mHeaderPaint.setColor(mHeaderColor);
|
||||
mHeaderPaint.setAlpha((int) (getAlpha() * Color.alpha(mHeaderColor)));
|
||||
if (mHeaderPaint.getColor() != mScrimColor && mHeaderPaint.getColor() != 0) {
|
||||
canvas.drawRect(0, 0, getWidth(), mSearchContainer.getTop() + getTranslationY(),
|
||||
int bottom = mUsingTabs && mHeader.mHeaderCollapsed ? mHeader.getVisibleBottomBound()
|
||||
: mSearchContainer.getBottom();
|
||||
canvas.drawRect(0, 0, getWidth(), bottom + getTranslationY(),
|
||||
mHeaderPaint);
|
||||
}
|
||||
}
|
||||
|
@ -781,13 +770,6 @@ public class AllAppsContainerView extends SpringRelativeLayout implements DragSo
|
|||
mAH[AdapterHolder.MAIN].recyclerView.setVerticalFadingEdgeEnabled(!mUsingTabs
|
||||
&& verticalFadingEdge);
|
||||
}
|
||||
|
||||
private View getOverlayView() {
|
||||
if (mOverlay == null) {
|
||||
mOverlay = mLauncher.getLayoutInflater().inflate(R.layout.work_apps_paused, null);
|
||||
}
|
||||
return mOverlay;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -447,4 +447,14 @@ public class AllAppsRecyclerView extends BaseRecyclerView {
|
|||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns distance between left and right app icons
|
||||
*/
|
||||
public int getTabWidth() {
|
||||
DeviceProfile grid = BaseDraggingActivity.fromContext(getContext()).getDeviceProfile();
|
||||
int totalWidth = (grid.availableWidthPx - getPaddingLeft() - getPaddingRight());
|
||||
int iconPadding = totalWidth / grid.numShownAllAppsColumns - grid.allAppsIconSizePx;
|
||||
return totalWidth - iconPadding;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,8 +72,13 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||
}
|
||||
|
||||
int current = -mCurrentRV.getCurrentScrollY();
|
||||
boolean headerCollapsed = mHeaderCollapsed;
|
||||
moved(current);
|
||||
applyVerticalMove();
|
||||
if (headerCollapsed != mHeaderCollapsed) {
|
||||
AllAppsContainerView parent = (AllAppsContainerView) getParent();
|
||||
parent.invalidateHeader();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -219,6 +224,8 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||
|
||||
mTabsHidden = tabsHidden;
|
||||
mTabLayout.setVisibility(tabsHidden ? View.GONE : View.VISIBLE);
|
||||
mTabLayout.getLayoutParams().width =
|
||||
mAH[AllAppsContainerView.AdapterHolder.MAIN].recyclerView.getTabWidth();
|
||||
mMainRV = setupRV(mMainRV, mAH[AllAppsContainerView.AdapterHolder.MAIN].recyclerView);
|
||||
mWorkRV = setupRV(mWorkRV, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView);
|
||||
mParent = (ViewGroup) mMainRV.getParent();
|
||||
|
@ -429,6 +436,13 @@ public class FloatingHeaderView extends LinearLayout implements
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns visible height of FloatingHeaderView contents
|
||||
*/
|
||||
public int getVisibleBottomBound() {
|
||||
return getBottom() + mTranslationY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
|
@ -29,7 +29,7 @@ import com.android.launcher3.R;
|
|||
/**
|
||||
* Work profile toggle switch shown at the bottom of AllApps work tab
|
||||
*/
|
||||
public class WorkEduCard extends LinearLayout implements View.OnClickListener,
|
||||
public class WorkEduCard extends FrameLayout implements View.OnClickListener,
|
||||
Animation.AnimationListener {
|
||||
|
||||
private final Launcher mLauncher;
|
||||
|
@ -52,11 +52,24 @@ public class WorkEduCard extends LinearLayout implements View.OnClickListener,
|
|||
mDismissAnim.setAnimationListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
mDismissAnim.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mDismissAnim.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
findViewById(R.id.action_btn).setOnClickListener(this);
|
||||
MarginLayoutParams lp = ((MarginLayoutParams) findViewById(R.id.wrapper).getLayoutParams());
|
||||
lp.width = mLauncher.getAppsView().getActiveRecyclerView().getTabWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,6 @@ import android.widget.Button;
|
|||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.android.launcher3.Insettable;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.pm.UserCache;
|
||||
|
||||
|
@ -79,7 +78,9 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi
|
|||
clearAnimation();
|
||||
if (workTabVisible) {
|
||||
setEnabled(true);
|
||||
setVisibility(VISIBLE);
|
||||
if (mWorkEnabled) {
|
||||
setVisibility(VISIBLE);
|
||||
}
|
||||
setAlpha(0);
|
||||
animate().alpha(1).start();
|
||||
} else {
|
||||
|
@ -91,7 +92,7 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi
|
|||
public void onClick(View view) {
|
||||
if (Utilities.ATLEAST_P) {
|
||||
setEnabled(false);
|
||||
UI_HELPER_EXECUTOR.post(() -> setToState(!mWorkEnabled));
|
||||
UI_HELPER_EXECUTOR.post(() -> setWorkProfileEnabled(getContext(), false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,20 +102,18 @@ public class WorkModeSwitch extends Button implements Insettable, View.OnClickLi
|
|||
public void updateCurrentState(boolean active) {
|
||||
mWorkEnabled = active;
|
||||
setEnabled(true);
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||
active ? R.drawable.ic_corp_off : R.drawable.ic_corp, 0, 0, 0);
|
||||
setText(active ? R.string.work_apps_pause_btn_text : R.string.work_apps_enable_btn_text);
|
||||
setVisibility(active ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.P)
|
||||
protected Boolean setToState(boolean toState) {
|
||||
UserManager userManager = getContext().getSystemService(UserManager.class);
|
||||
public static Boolean setWorkProfileEnabled(Context context, boolean enabled) {
|
||||
UserManager userManager = context.getSystemService(UserManager.class);
|
||||
boolean showConfirm = false;
|
||||
for (UserHandle userProfile : UserCache.INSTANCE.get(getContext()).getUserProfiles()) {
|
||||
for (UserHandle userProfile : UserCache.INSTANCE.get(context).getUserProfiles()) {
|
||||
if (Process.myUserHandle().equals(userProfile)) {
|
||||
continue;
|
||||
}
|
||||
showConfirm |= !userManager.requestQuietModeEnabled(!toState, userProfile);
|
||||
showConfirm |= !userManager.requestQuietModeEnabled(!enabled, userProfile);
|
||||
}
|
||||
return showConfirm;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (C) 2020 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.allapps;
|
||||
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
/**
|
||||
* Work profile toggle switch shown at the bottom of AllApps work tab
|
||||
*/
|
||||
public class WorkPausedCard extends LinearLayout implements View.OnClickListener {
|
||||
|
||||
private final Launcher mLauncher;
|
||||
private Button mBtn;
|
||||
|
||||
public WorkPausedCard(Context context) {
|
||||
this(context, null, 0);
|
||||
}
|
||||
|
||||
public WorkPausedCard(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public WorkPausedCard(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
mLauncher = Launcher.getLauncher(getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mBtn = findViewById(R.id.enable_work_apps);
|
||||
mBtn.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (Utilities.ATLEAST_P) {
|
||||
setEnabled(false);
|
||||
UI_HELPER_EXECUTOR.post(() -> WorkModeSwitch.setWorkProfileEnabled(getContext(), true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
int orientation = getResources().getConfiguration().orientation;
|
||||
getLayoutParams().height = orientation == Configuration.ORIENTATION_PORTRAIT
|
||||
? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT;
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue