Using GridLayout in AppsCustomize widgets tab.
- Starting to implement new widgets design - Hiding outlines in phone ui while dragging - Making the tab bar show only when we have items as well Change-Id: Ic027f9ba83fc0982f2f92a90412f050a8e248f9c
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 108 B |
Binary file not shown.
|
After Width: | Height: | Size: 168 B |
Binary file not shown.
|
After Width: | Height: | Size: 108 B |
Binary file not shown.
|
After Width: | Height: | Size: 178 B |
Binary file not shown.
|
Before Width: | Height: | Size: 2.9 KiB |
@@ -23,6 +23,7 @@
|
||||
<!-- The layout_width of the tab bar gets overriden to align the content
|
||||
with the text in the tabs in AppsCustomizeTabHost. -->
|
||||
<FrameLayout
|
||||
android:id="@+id/tabs_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/qsb_bar_height"
|
||||
android:layout_gravity="center_horizontal">
|
||||
|
||||
@@ -28,58 +28,53 @@
|
||||
android:background="@drawable/focusable_view_bg"
|
||||
android:focusable="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/widget_info_bg">
|
||||
<!-- The name of the widget. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="left|bottom"
|
||||
|
||||
android:textColor="#FFBBBBBB"
|
||||
android:textSize="14sp"
|
||||
android:shadowColor="#FF000000"
|
||||
android:shadowDx="0.0"
|
||||
android:shadowDy="1.0"
|
||||
android:shadowRadius="1.0"
|
||||
|
||||
android:maxLines="2"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
<!-- The original dimensions of the widget (can't be the same text as above due to different
|
||||
style. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_dims"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="left|bottom"
|
||||
|
||||
android:textColor="#FF999999"
|
||||
android:textSize="12sp"
|
||||
android:shadowColor="#99000000"
|
||||
android:shadowDx="0.0"
|
||||
android:shadowDy="1.0"
|
||||
android:shadowRadius="1.0" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- The icon of the widget. -->
|
||||
<ImageView
|
||||
android:id="@+id/widget_preview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:paddingBottom="5dp"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart" />
|
||||
|
||||
<!-- The divider image.
|
||||
This view is removed in PagedViewWidget.java in the Phone UI. -->
|
||||
<ImageView
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:src="@drawable/widget_divider" />
|
||||
|
||||
<!-- The name of the widget. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="left|bottom"
|
||||
|
||||
android:textColor="#FFFFFFFF"
|
||||
android:textSize="14sp"
|
||||
android:shadowColor="#FF000000"
|
||||
android:shadowDx="0.0"
|
||||
android:shadowDy="1.0"
|
||||
android:shadowRadius="1.0"
|
||||
|
||||
android:maxLines="2"
|
||||
android:fadingEdge="horizontal" />
|
||||
|
||||
<!-- The original dimensions of the widget (can't be the same text as above due to different
|
||||
style. -->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_dims"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="left|bottom"
|
||||
|
||||
android:textColor="#FF999999"
|
||||
android:textSize="14sp"
|
||||
android:shadowColor="#99000000"
|
||||
android:shadowDx="0.0"
|
||||
android:shadowDy="1.0"
|
||||
android:shadowRadius="1.0" />
|
||||
</com.android.launcher2.PagedViewWidget>
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.widget.GridLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
@@ -237,7 +238,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
* This differs from isDataReady as this is the test done if isDataReady is not set.
|
||||
*/
|
||||
private boolean testDataReady() {
|
||||
return !mApps.isEmpty() && !mWidgets.isEmpty();
|
||||
// We only do this test once, and we default to the Applications page, so we only really
|
||||
// have to wait for there to be apps.
|
||||
return !mApps.isEmpty();
|
||||
}
|
||||
|
||||
protected void onDataReady(int width, int height) {
|
||||
@@ -512,7 +515,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
// expected page width, so we can actually optimize by hiding all the TextView-based
|
||||
// children that are expensive to measure, and let that happen naturally later.
|
||||
setVisibilityOnChildren(layout, View.GONE);
|
||||
int widthSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST);
|
||||
int widthSpec = MeasureSpec.makeMeasureSpec(getPageContentWidth(), MeasureSpec.AT_MOST);
|
||||
int heightSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), MeasureSpec.AT_MOST);
|
||||
layout.setMinimumWidth(getPageContentWidth());
|
||||
layout.measure(widthSpec, heightSpec);
|
||||
@@ -892,10 +895,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
||||
// Layout each widget
|
||||
int ix = i % mWidgetCountX;
|
||||
int iy = i / mWidgetCountX;
|
||||
PagedViewGridLayout.LayoutParams lp = new PagedViewGridLayout.LayoutParams(cellWidth,
|
||||
cellHeight);
|
||||
lp.leftMargin = (ix * cellWidth) + (ix * mWidgetWidthGap);
|
||||
lp.topMargin = (iy * cellHeight) + (iy * mWidgetHeightGap);
|
||||
GridLayout.LayoutParams lp = new GridLayout.LayoutParams(
|
||||
new GridLayout.Group(iy, 1, GridLayout.LEFT),
|
||||
new GridLayout.Group(ix, 1, GridLayout.TOP));
|
||||
lp.width = cellWidth;
|
||||
lp.height = cellHeight;
|
||||
if (ix > 0) lp.leftMargin = mWidgetWidthGap;
|
||||
if (iy > 0) lp.topMargin = mWidgetHeightGap;
|
||||
layout.addView(widget, lp);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,11 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
||||
|
||||
private static final String APPS_TAB_TAG = "APPS";
|
||||
private static final String WIDGETS_TAB_TAG = "WIDGETS";
|
||||
private static final int sTabBarFadeInDuration = 150;
|
||||
|
||||
private final LayoutInflater mLayoutInflater;
|
||||
private ViewGroup mTabs;
|
||||
private ViewGroup mTabsContainer;
|
||||
private AppsCustomizePagedView mAppsCustomizePane;
|
||||
|
||||
public AppsCustomizeTabHost(Context context, AttributeSet attrs) {
|
||||
@@ -67,10 +69,12 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
||||
// Setup the tab host
|
||||
setup();
|
||||
|
||||
final ViewGroup tabsContainer = (ViewGroup) findViewById(R.id.tabs_container);
|
||||
final TabWidget tabs = (TabWidget) findViewById(com.android.internal.R.id.tabs);
|
||||
final AppsCustomizePagedView appsCustomizePane = (AppsCustomizePagedView)
|
||||
findViewById(R.id.apps_customize_pane_content);
|
||||
mTabs = tabs;
|
||||
mTabsContainer = tabsContainer;
|
||||
mAppsCustomizePane = appsCustomizePane;
|
||||
if (tabs == null || mAppsCustomizePane == null) throw new Resources.NotFoundException();
|
||||
|
||||
@@ -98,6 +102,9 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
||||
lastTab.setOnKeyListener(keyListener);
|
||||
View shopButton = findViewById(R.id.market_button);
|
||||
shopButton.setOnKeyListener(keyListener);
|
||||
|
||||
// Hide the tab bar until we measure
|
||||
mTabsContainer.setAlpha(0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,9 +114,15 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
|
||||
|
||||
// Set the width of the tab list to the content width
|
||||
if (remeasureTabWidth) {
|
||||
mTabs.getLayoutParams().width = mAppsCustomizePane.getPageContentWidth();
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int contentWidth = mAppsCustomizePane.getPageContentWidth();
|
||||
if (contentWidth > 0) {
|
||||
// Set the width and show the tab bar (if we have a loading graphic, we can switch
|
||||
// it off here)
|
||||
mTabs.getLayoutParams().width = contentWidth;
|
||||
mTabsContainer.animate().alpha(1f).setDuration(sTabBarFadeInDuration);
|
||||
}
|
||||
}
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,14 +19,13 @@ package com.android.launcher2;
|
||||
import android.content.Context;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.GridLayout;
|
||||
|
||||
/**
|
||||
* The grid based layout used strictly for the widget/wallpaper tab of the AppsCustomize pane
|
||||
*/
|
||||
public class PagedViewGridLayout extends FrameLayout implements Page {
|
||||
public class PagedViewGridLayout extends GridLayout implements Page {
|
||||
static final String TAG = "PagedViewGridLayout";
|
||||
|
||||
private int mCellCountX;
|
||||
@@ -36,6 +35,7 @@ public class PagedViewGridLayout extends FrameLayout implements Page {
|
||||
super(context, null, 0);
|
||||
mCellCountX = cellCountX;
|
||||
mCellCountY = cellCountY;
|
||||
setColumnCount(mCellCountX);
|
||||
}
|
||||
|
||||
int getCellCountX() {
|
||||
@@ -50,9 +50,9 @@ public class PagedViewGridLayout extends FrameLayout implements Page {
|
||||
// offset of each page to scroll to before it updates the actual size of each page
|
||||
// (which can change depending on the content if the contents aren't a fixed size).
|
||||
// We work around this by having a minimum size on each widget page).
|
||||
int widthSpecSize = Math.max(getSuggestedMinimumWidth(),
|
||||
int widthSpecSize = Math.min(getSuggestedMinimumWidth(),
|
||||
MeasureSpec.getSize(widthMeasureSpec));
|
||||
int widthSpecMode = MeasureSpec.AT_MOST;
|
||||
int widthSpecMode = MeasureSpec.EXACTLY;
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(widthSpecSize, widthSpecMode),
|
||||
heightMeasureSpec);
|
||||
}
|
||||
|
||||
@@ -112,11 +112,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
||||
final TextView dims = (TextView) findViewById(R.id.widget_dims);
|
||||
dims.setText(String.format(mDimensionsFormatString, cellSpan[0], cellSpan[1]));
|
||||
dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
// Hide the divider in the Phone UI.
|
||||
if (!LauncherApplication.isScreenLarge()) {
|
||||
findViewById(R.id.divider).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyFromResolveInfo(PackageManager pm, ResolveInfo info,
|
||||
@@ -133,11 +128,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
||||
dims.setText(String.format(mDimensionsFormatString, 1, 1));
|
||||
dims.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
|
||||
// Hide the divider in the Phone UI.
|
||||
if (!LauncherApplication.isScreenLarge()) {
|
||||
findViewById(R.id.divider).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHolographicOutline(Bitmap holoOutline) {
|
||||
@@ -184,7 +174,8 @@ public class PagedViewWidget extends LinearLayout implements Checkable {
|
||||
mPaint.setAlpha(mHolographicAlpha);
|
||||
canvas.save();
|
||||
canvas.scale(mTmpScaleRect.right, mTmpScaleRect.bottom);
|
||||
canvas.drawBitmap(mHolographicOutline, 0, 0, mPaint);
|
||||
canvas.drawBitmap(mHolographicOutline, mPreviewImageView.getLeft(),
|
||||
mPreviewImageView.getTop(), mPaint);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ public class Workspace extends SmoothPagedView
|
||||
|
||||
try {
|
||||
final Resources res = getResources();
|
||||
mBackground = res.getDrawable(R.drawable.all_apps_bg_gradient);
|
||||
mBackground = res.getDrawable(R.drawable.apps_customize_bg);
|
||||
} catch (Resources.NotFoundException e) {
|
||||
// In this case, we will skip drawing background protection
|
||||
}
|
||||
@@ -2549,7 +2549,12 @@ public class Workspace extends SmoothPagedView
|
||||
if (!mIsSmall) {
|
||||
mDragTargetLayout = getCurrentDropLayout();
|
||||
mDragTargetLayout.onDragEnter();
|
||||
showOutlines();
|
||||
|
||||
// Because we don't have space in the Phone UI (the CellLayouts run to the edge) we
|
||||
// don't need to show the outlines
|
||||
if (!LauncherApplication.isScreenLarge()) {
|
||||
showOutlines();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user