Merge "Using BubbleTextView for widget section headers" into ub-launcher3-burnaby
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:launcher="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/widgets_cell_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -23,36 +24,29 @@
|
||||
android:descendantFocusability="afterDescendants">
|
||||
|
||||
<!-- Section info -->
|
||||
<LinearLayout
|
||||
|
||||
<com.android.launcher3.BubbleTextView
|
||||
android:id="@+id/section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_height="@dimen/widget_section_height"
|
||||
android:background="@color/widget_text_panel"
|
||||
android:drawablePadding="@dimen/widget_section_horizontal_padding"
|
||||
android:ellipsize="end"
|
||||
android:focusable="true"
|
||||
android:descendantFocusability="afterDescendants">
|
||||
<ImageView
|
||||
android:id="@+id/section_image"
|
||||
android:layout_height="@dimen/widget_section_height"
|
||||
android:layout_width="@dimen/widget_section_icon_width"
|
||||
android:paddingLeft="@dimen/widget_section_icon_horizontal_padding"
|
||||
android:paddingRight="@dimen/widget_section_icon_horizontal_padding"
|
||||
android:paddingTop="@dimen/widget_section_icon_vertical_padding"
|
||||
android:paddingBottom="@dimen/widget_section_icon_vertical_padding"
|
||||
android:background="@color/widget_text_panel"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/widget_section_height"
|
||||
android:paddingEnd="@dimen/widget_preview_label_horizontal_padding"
|
||||
android:paddingRight="@dimen/widget_preview_label_horizontal_padding"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"
|
||||
android:gravity="start|center_vertical"
|
||||
android:textColor="@color/widgets_view_section_text_color"
|
||||
android:background="@color/widget_text_panel"
|
||||
android:textSize="20sp"
|
||||
android:focusable="false" />
|
||||
</LinearLayout>
|
||||
android:gravity="start|center_vertical"
|
||||
android:importantForAccessibility="no"
|
||||
android:paddingBottom="@dimen/widget_section_vertical_padding"
|
||||
android:paddingLeft="@dimen/widget_section_horizontal_padding"
|
||||
android:paddingRight="@dimen/widget_section_horizontal_padding"
|
||||
android:paddingTop="@dimen/widget_section_vertical_padding"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/widgets_view_section_text_color"
|
||||
android:textSize="20sp"
|
||||
launcher:customShadows="false"
|
||||
launcher:deferShadowGeneration="true"
|
||||
launcher:iconDisplay="widget_section"
|
||||
launcher:iconSizeOverride="@dimen/widget_section_icon_size"
|
||||
launcher:layoutHorizontal="true" />
|
||||
|
||||
<!-- Widget list -->
|
||||
<com.android.launcher3.widget.WidgetRowView
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<attr name="iconDisplay" format="integer">
|
||||
<enum name="workspace" value="0" />
|
||||
<enum name="all_apps" value="1" />
|
||||
<enum name="widget_section" value="2" />
|
||||
</attr>
|
||||
<attr name="deferShadowGeneration" format="boolean" />
|
||||
<attr name="customShadows" format="boolean" />
|
||||
|
||||
@@ -95,9 +95,9 @@
|
||||
<dimen name="widget_preview_horizontal_padding">8dp</dimen>
|
||||
|
||||
<dimen name="widget_section_height">56dp</dimen>
|
||||
<dimen name="widget_section_icon_width">72dp</dimen>
|
||||
<dimen name="widget_section_icon_vertical_padding">8dp</dimen>
|
||||
<dimen name="widget_section_icon_horizontal_padding">16dp</dimen>
|
||||
<dimen name="widget_section_icon_size">40dp</dimen>
|
||||
<dimen name="widget_section_vertical_padding">8dp</dimen>
|
||||
<dimen name="widget_section_horizontal_padding">16dp</dimen>
|
||||
|
||||
<!-- Equation: widget_preview_size + 2 * widget_preview_padding_horizontal -->
|
||||
<dimen name="widget_preview_container_width">146dp</dimen>
|
||||
|
||||
@@ -28,13 +28,13 @@ import android.graphics.drawable.Drawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.launcher3.IconCache.IconLoadRequest;
|
||||
import com.android.launcher3.widget.PackageItemInfo;
|
||||
|
||||
/**
|
||||
* TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan
|
||||
@@ -119,11 +119,6 @@ public class BubbleTextView extends TextView {
|
||||
mBackground = null;
|
||||
}
|
||||
|
||||
// If we are laying out horizontal, then center the text vertically
|
||||
if (mLayoutHorizontal) {
|
||||
setGravity(Gravity.CENTER_VERTICAL);
|
||||
}
|
||||
|
||||
mLongPressHelper = new CheckLongPressHelper(this);
|
||||
|
||||
mOutlineHelper = HolographicOutlineHelper.obtain(getContext());
|
||||
@@ -170,6 +165,20 @@ public class BubbleTextView extends TextView {
|
||||
verifyHighRes();
|
||||
}
|
||||
|
||||
public void applyFromPackageItemInfo(PackageItemInfo info) {
|
||||
setIcon(Utilities.createIconDrawable(info.iconBitmap), mIconSize);
|
||||
setText(info.title);
|
||||
if (info.contentDescription != null) {
|
||||
setContentDescription(info.contentDescription);
|
||||
}
|
||||
// We don't need to check the info since it's not a ShortcutInfo
|
||||
super.setTag(info);
|
||||
|
||||
// Verify high res immediately
|
||||
verifyHighRes();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean setFrame(int left, int top, int right, int bottom) {
|
||||
if (getLeft() != left || getRight() != right || getTop() != top || getBottom() != bottom) {
|
||||
@@ -459,6 +468,8 @@ public class BubbleTextView extends TextView {
|
||||
} else if (info instanceof ShortcutInfo) {
|
||||
applyFromShortcutInfo((ShortcutInfo) info,
|
||||
LauncherAppState.getInstance().getIconCache());
|
||||
} else if (info instanceof PackageItemInfo) {
|
||||
applyFromPackageItemInfo((PackageItemInfo) info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,6 +494,12 @@ public class BubbleTextView extends TextView {
|
||||
mIconLoadRequest = LauncherAppState.getInstance().getIconCache()
|
||||
.updateIconInBackground(BubbleTextView.this, info);
|
||||
}
|
||||
} else if (getTag() instanceof PackageItemInfo) {
|
||||
PackageItemInfo info = (PackageItemInfo) getTag();
|
||||
if (info.usingLowResIcon) {
|
||||
mIconLoadRequest = LauncherAppState.getInstance().getIconCache()
|
||||
.updateIconInBackground(BubbleTextView.this, info);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +374,9 @@ public class IconCache {
|
||||
getTitleAndIcon(st,
|
||||
st.promisedIntent != null ? st.promisedIntent : st.intent,
|
||||
st.user, false);
|
||||
} else if (info instanceof PackageItemInfo) {
|
||||
PackageItemInfo pti = (PackageItemInfo) info;
|
||||
getTitleAndIconForApp(pti.packageName, pti.user, false, pti);
|
||||
}
|
||||
mMainThreadExecutor.execute(new Runnable() {
|
||||
|
||||
|
||||
@@ -17,22 +17,21 @@ package com.android.launcher3.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.IconCache;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.WidgetPreviewLoader;
|
||||
import com.android.launcher3.compat.UserHandleCompat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -120,16 +119,8 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
|
||||
|
||||
// Bind the views in the application info section.
|
||||
PackageItemInfo infoOut = mWidgetsModel.getPackageItemInfo(pos);
|
||||
if (infoOut.usingLowResIcon) {
|
||||
// TODO(hyunyoungs): call this in none UI thread in the same way as BubbleTextView.
|
||||
mIconCache.getTitleAndIconForApp(infoOut.packageName,
|
||||
UserHandleCompat.myUserHandle(), false /* useLowResIcon */, infoOut);
|
||||
}
|
||||
|
||||
TextView tv = ((TextView) holder.getContent().findViewById(R.id.section));
|
||||
tv.setText(infoOut.title);
|
||||
ImageView iv = (ImageView) holder.getContent().findViewById(R.id.section_image);
|
||||
iv.setImageBitmap(infoOut.iconBitmap);
|
||||
BubbleTextView tv = ((BubbleTextView) holder.getContent().findViewById(R.id.section));
|
||||
tv.applyFromPackageItemInfo(infoOut);
|
||||
|
||||
// Bind the view in the widget horizontal tray region.
|
||||
for (int i=0; i < infoList.size(); i++) {
|
||||
|
||||
Reference in New Issue
Block a user