mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Adding an upper bound to all-apps width on larger devices
Change-Id: I16a0d8fb7c5023045d0a6b9e8089e0ab6a476d6d
This commit is contained in:
@@ -18,4 +18,7 @@
|
||||
<!-- QSB -->
|
||||
<dimen name="toolbar_button_vertical_padding">12dip</dimen>
|
||||
<dimen name="toolbar_button_horizontal_padding">20dip</dimen>
|
||||
|
||||
<!-- Container -->
|
||||
<dimen name="container_max_width">736dp</dimen>
|
||||
</resources>
|
||||
|
||||
20
res/values-sw768dp-port/dimens.xml
Normal file
20
res/values-sw768dp-port/dimens.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?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.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- Container -->
|
||||
<dimen name="container_max_width">736dp</dimen>
|
||||
</resources>
|
||||
@@ -69,6 +69,7 @@
|
||||
|
||||
<item name="container_margin" format="fraction" type="fraction">0%</item>
|
||||
<dimen name="container_min_margin">8dp</dimen>
|
||||
<dimen name="container_max_width">0dp</dimen>
|
||||
|
||||
<!-- All Apps -->
|
||||
<dimen name="all_apps_button_scale_down">0dp</dimen>
|
||||
|
||||
@@ -18,16 +18,12 @@ package com.android.launcher3;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.InsetDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.config.ProviderConfig;
|
||||
|
||||
/**
|
||||
* A base container view, which supports resizing.
|
||||
*/
|
||||
@@ -52,9 +48,7 @@ public abstract class BaseContainerView extends FrameLayout {
|
||||
super(context, attrs, defStyleAttr);
|
||||
|
||||
int width = ((Launcher) context).getDeviceProfile().availableWidthPx;
|
||||
mHorizontalPadding = Math.max(
|
||||
getResources().getDimensionPixelSize(R.dimen.container_min_margin),
|
||||
(int) getResources().getFraction(R.fraction.container_margin, width, 1));
|
||||
mHorizontalPadding = DeviceProfile.getMaxContainerWidth(context, width);
|
||||
|
||||
TypedArray a = context.obtainStyledAttributes(attrs,
|
||||
R.styleable.BaseContainerView, defStyleAttr, 0);
|
||||
|
||||
@@ -594,4 +594,19 @@ public class DeviceProfile {
|
||||
? Math.min(widthPx, heightPx)
|
||||
: Math.max(widthPx, heightPx);
|
||||
}
|
||||
|
||||
|
||||
public static final int getMaxContainerWidth(Context context, int availableWidth) {
|
||||
Resources res = context.getResources();
|
||||
|
||||
int maxSize = res.getDimensionPixelSize(R.dimen.container_max_width);
|
||||
int minMargin = res.getDimensionPixelSize(R.dimen.container_min_margin);
|
||||
|
||||
if (maxSize > 0) {
|
||||
return Math.max(minMargin, (availableWidth - maxSize) / 2);
|
||||
} else {
|
||||
return Math.max(minMargin,
|
||||
(int) res.getFraction(R.fraction.container_margin, availableWidth, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user