Merge "Defining separate layouts for horizontal and vertical drop target bars instead of chaning the layouts in DeviceProfile" into ub-launcher3-calgary
This commit is contained in:
@@ -52,11 +52,11 @@
|
||||
|
||||
<include
|
||||
android:id="@+id/app_info_drop_target_bar"
|
||||
layout="@layout/app_info_drop_target_bar" />
|
||||
layout="@layout/drop_target_bar_vert_info" />
|
||||
|
||||
<include
|
||||
android:id="@+id/search_drop_target_bar"
|
||||
layout="@layout/search_drop_target_bar" />
|
||||
layout="@layout/drop_target_bar_vert_search" />
|
||||
|
||||
<include layout="@layout/overview_panel"
|
||||
android:id="@+id/overview_panel"
|
||||
|
||||
@@ -66,11 +66,11 @@
|
||||
|
||||
<include
|
||||
android:id="@+id/app_info_drop_target_bar"
|
||||
layout="@layout/app_info_drop_target_bar" />
|
||||
layout="@layout/drop_target_bar_horz_info" />
|
||||
|
||||
<include
|
||||
android:id="@+id/search_drop_target_bar"
|
||||
layout="@layout/search_drop_target_bar" />
|
||||
layout="@layout/drop_target_bar_horz_search" />
|
||||
|
||||
<include layout="@layout/widgets_view"
|
||||
android:id="@+id/widgets_view"
|
||||
|
||||
@@ -52,11 +52,11 @@
|
||||
|
||||
<include
|
||||
android:id="@+id/app_info_drop_target_bar"
|
||||
layout="@layout/app_info_drop_target_bar" />
|
||||
layout="@layout/drop_target_bar_horz_info" />
|
||||
|
||||
<include
|
||||
android:id="@+id/search_drop_target_bar"
|
||||
layout="@layout/search_drop_target_bar" />
|
||||
layout="@layout/drop_target_bar_horz_search" />
|
||||
|
||||
<include layout="@layout/overview_panel"
|
||||
android:id="@+id/overview_panel"
|
||||
|
||||
+15
-18
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2011 The Android Open Source Project
|
||||
Copyright (C) 2016 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.
|
||||
@@ -16,27 +16,24 @@
|
||||
-->
|
||||
<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:focusable="false" >
|
||||
|
||||
<!-- Drag specific targets container -->
|
||||
<LinearLayout
|
||||
<FrameLayout
|
||||
android:id="@+id/drag_target_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center|bottom" >
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
style="@style/DropTargetButtonContainer"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<!-- Info target -->
|
||||
|
||||
<com.android.launcher3.InfoDropTarget
|
||||
android:id="@+id/info_target_text"
|
||||
style="@style/DropTargetButton"
|
||||
android:text="@string/app_info_drop_target_label" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
<!-- Info target -->
|
||||
|
||||
<com.android.launcher3.InfoDropTarget
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:id="@+id/info_target_text"
|
||||
style="@style/DropTargetButton"
|
||||
android:text="@string/app_info_drop_target_label" />
|
||||
</FrameLayout>
|
||||
</com.android.launcher3.AppInfoDropTargetBar>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2011 The Android Open Source Project
|
||||
Copyright (C) 2015 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.
|
||||
@@ -15,9 +15,11 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
<com.android.launcher3.SearchDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:launcher="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false" >
|
||||
android:layout_gravity="center_horizontal|top"
|
||||
android:focusable="false">
|
||||
|
||||
<!-- Drag specific targets container -->
|
||||
|
||||
@@ -28,24 +30,36 @@
|
||||
android:layout_gravity="center" >
|
||||
|
||||
<FrameLayout
|
||||
style="@style/DropTargetButtonContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<!-- Delete target -->
|
||||
|
||||
<com.android.launcher3.DeleteDropTarget
|
||||
launcher:hideParentOnDisable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:id="@+id/delete_target_text"
|
||||
style="@style/DropTargetButton"
|
||||
android:text="@string/remove_drop_target_label" />
|
||||
</FrameLayout>
|
||||
|
||||
<FrameLayout
|
||||
style="@style/DropTargetButtonContainer"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" >
|
||||
|
||||
<!-- Uninstall target -->
|
||||
|
||||
<com.android.launcher3.UninstallDropTarget
|
||||
launcher:hideParentOnDisable="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:id="@+id/uninstall_target_text"
|
||||
style="@style/DropTargetButton"
|
||||
android:text="@string/uninstall_drop_target_label" />
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2016 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.
|
||||
-->
|
||||
<com.android.launcher3.AppInfoDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/drag_target_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- Info target -->
|
||||
<com.android.launcher3.InfoDropTarget
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="14dp"
|
||||
android:paddingRight="14dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:id="@+id/info_target_text" />
|
||||
</FrameLayout>
|
||||
|
||||
</com.android.launcher3.AppInfoDropTargetBar>
|
||||
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 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.
|
||||
-->
|
||||
<com.android.launcher3.SearchDropTargetBar xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="match_parent"
|
||||
android:focusable="false">
|
||||
|
||||
<!-- Drag specific targets container -->
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/drag_target_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center"
|
||||
android:paddingTop="20dp">
|
||||
|
||||
<!-- Delete target -->
|
||||
<com.android.launcher3.DeleteDropTarget
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="14dp"
|
||||
android:paddingRight="14dp"
|
||||
android:id="@+id/delete_target_text"
|
||||
android:textColor="@android:color/white"
|
||||
android:layout_marginBottom="10dp" />
|
||||
|
||||
<!-- Uninstall target -->
|
||||
<com.android.launcher3.UninstallDropTarget
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="14dp"
|
||||
android:paddingRight="14dp"
|
||||
android:id="@+id/uninstall_target_text"
|
||||
android:textColor="@android:color/white"
|
||||
android:layout_marginTop="10dp"/>
|
||||
</LinearLayout>
|
||||
|
||||
</com.android.launcher3.SearchDropTargetBar>
|
||||
@@ -15,10 +15,6 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- QSB -->
|
||||
<dimen name="toolbar_button_vertical_padding">8dip</dimen>
|
||||
<dimen name="toolbar_button_horizontal_padding">0dip</dimen>
|
||||
|
||||
<!-- Container -->
|
||||
<item name="container_margin" format="fraction" type="fraction">12%</item>
|
||||
</resources>
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
* Copyright (C) 2008 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.
|
||||
*/
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<style name="DropTargetButtonContainer">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
</style>
|
||||
|
||||
<!-- This style applies to the drop target when it is shown in the sidebar -->
|
||||
<style name="DropTargetButton" parent="DropTargetButtonBase">
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:drawablePadding">0dp</item>
|
||||
<item name="android:paddingTop">@dimen/toolbar_button_vertical_padding</item>
|
||||
<item name="android:paddingBottom">@dimen/toolbar_button_vertical_padding</item>
|
||||
<item name="android:paddingLeft">@dimen/toolbar_button_horizontal_padding</item>
|
||||
<item name="android:paddingRight">@dimen/toolbar_button_horizontal_padding</item>
|
||||
<item name="android:shadowColor">#DD000000</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
@@ -28,11 +28,6 @@
|
||||
</style>
|
||||
|
||||
<!-- Workspace -->
|
||||
<style name="DropTargetButtonContainer">
|
||||
<item name="android:layout_width">0dp</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
</style>
|
||||
|
||||
<style name="DropTargetButton" parent="DropTargetButtonBase">
|
||||
<item name="android:paddingLeft">60dp</item>
|
||||
<item name="android:paddingRight">60dp</item>
|
||||
|
||||
@@ -83,4 +83,8 @@
|
||||
<declare-styleable name="InsettableFrameLayout_Layout">
|
||||
<attr name="layout_ignoreInsets" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ButtonDropTarget">
|
||||
<attr name="hideParentOnDisable" format="boolean" />
|
||||
</declare-styleable>
|
||||
</resources>
|
||||
|
||||
@@ -71,16 +71,7 @@
|
||||
</style>
|
||||
|
||||
<!-- Drop targets -->
|
||||
<style name="DropTargetButtonContainer">
|
||||
<item name="android:layout_width">0dp</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
</style>
|
||||
|
||||
<style name="DropTargetButtonBase">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:layout_gravity">center</item>
|
||||
<item name="android:gravity">center_vertical</item>
|
||||
<item name="android:drawablePadding">7.5dp</item>
|
||||
<item name="android:paddingLeft">25dp</item>
|
||||
<item name="android:paddingRight">25dp</item>
|
||||
|
||||
@@ -24,11 +24,13 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
@@ -52,6 +54,8 @@ public abstract class ButtonDropTarget extends TextView
|
||||
|
||||
private static final int DRAG_VIEW_DROP_DURATION = 285;
|
||||
|
||||
private final boolean mHideParentOnDisable;
|
||||
|
||||
protected Launcher mLauncher;
|
||||
private int mBottomDragPadding;
|
||||
protected BaseDropTargetBar mDropTargetBar;
|
||||
@@ -65,12 +69,9 @@ public abstract class ButtonDropTarget extends TextView
|
||||
protected ColorStateList mOriginalTextColor;
|
||||
protected Drawable mDrawable;
|
||||
|
||||
protected DeviceProfile mDeviceProfile;
|
||||
|
||||
private AnimatorSet mCurrentColorAnim;
|
||||
@Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter;
|
||||
|
||||
|
||||
public ButtonDropTarget(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
@@ -78,18 +79,17 @@ public abstract class ButtonDropTarget extends TextView
|
||||
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.ButtonDropTarget, defStyle, 0);
|
||||
mHideParentOnDisable = a.getBoolean(R.styleable.ButtonDropTarget_hideParentOnDisable, false);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
mOriginalTextColor = getTextColors();
|
||||
|
||||
// Remove the text in the Phone UI in landscape
|
||||
mDeviceProfile = ((Launcher) getContext()).getDeviceProfile();
|
||||
if (mDeviceProfile.isVerticalBarLayout()) {
|
||||
setText("");
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@@ -203,7 +203,8 @@ public abstract class ButtonDropTarget extends TextView
|
||||
mCurrentColorAnim = null;
|
||||
}
|
||||
setTextColor(mOriginalTextColor);
|
||||
((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE);
|
||||
(mHideParentOnDisable ? ((ViewGroup) getParent()) : this)
|
||||
.setVisibility(mActive ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.android.launcher3;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.animation.AnimationUtils;
|
||||
@@ -69,7 +70,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
|
||||
* Set the drop target's text to either "Remove" or "Cancel" depending on the drag source.
|
||||
*/
|
||||
public void setTextBasedOnDragSource(DragSource dragSource) {
|
||||
if (!mDeviceProfile.isVerticalBarLayout()) {
|
||||
if (!TextUtils.isEmpty(getText())) {
|
||||
setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label
|
||||
: android.R.string.cancel);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
@@ -469,7 +468,7 @@ public class DeviceProfile {
|
||||
// Layout the search bar space
|
||||
Rect searchBarBounds = getSearchBarBounds(isLayoutRtl);
|
||||
View searchBar = launcher.getSearchDropTargetBar();
|
||||
lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP);
|
||||
lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams();
|
||||
lp.width = searchBarBounds.width();
|
||||
lp.height = searchBarBounds.height();
|
||||
lp.topMargin = searchBarTopExtraPaddingPx;
|
||||
@@ -477,7 +476,7 @@ public class DeviceProfile {
|
||||
|
||||
// Layout the app info bar space
|
||||
View appInfoBar = launcher.getAppInfoDropTargetBar();
|
||||
lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, appInfoBar, Gravity.BOTTOM);
|
||||
lp = (FrameLayout.LayoutParams) appInfoBar.getLayoutParams();
|
||||
lp.bottomMargin = hotseatBarHeightPx;
|
||||
appInfoBar.setLayoutParams(lp);
|
||||
|
||||
@@ -584,28 +583,6 @@ public class DeviceProfile {
|
||||
}
|
||||
}
|
||||
|
||||
private FrameLayout.LayoutParams getDropTargetBarLayoutParams(boolean hasVerticalBarLayout,
|
||||
View dropTargetBar, int verticalGravity) {
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) dropTargetBar.getLayoutParams();
|
||||
if (hasVerticalBarLayout) {
|
||||
// Vertical drop target bar space -- The drop target bar is fixed in the layout to be on
|
||||
// the left of the screen regardless of RTL
|
||||
lp.gravity = Gravity.LEFT;
|
||||
lp.width = normalSearchBarSpaceHeightPx;
|
||||
|
||||
LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar);
|
||||
targets.setOrientation(LinearLayout.VERTICAL);
|
||||
FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams();
|
||||
targetsLp.gravity = verticalGravity;
|
||||
targetsLp.height = LayoutParams.WRAP_CONTENT;
|
||||
} else {
|
||||
// Horizontal drop target bar space
|
||||
lp.gravity = verticalGravity | Gravity.CENTER_HORIZONTAL;
|
||||
lp.height = searchBarSpaceHeightPx;
|
||||
}
|
||||
return lp;
|
||||
}
|
||||
|
||||
private int getCurrentWidth() {
|
||||
return isLandscape
|
||||
? Math.max(widthPx, heightPx)
|
||||
|
||||
Reference in New Issue
Block a user