Fix issues with the new widget layout
-> use first layout instead of first measure to determine size -> fix issue where we were doubly accounting for padding of AppsCustomizePagedView -> show page backgrounds by default, hide fake page by default -> stripping some dead code related to the market button and all apps cling Change-Id: I787bdf1092c821b780670098fb219a8a68914bc8
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 646 B |
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 449 B |
Before Width: | Height: | Size: 951 B After Width: | Height: | Size: 894 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -40,6 +40,7 @@
|
|||
android:id="@+id/fake_page"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="invisible"
|
||||
android:clipToPadding="false" />
|
||||
</FrameLayout>
|
||||
<com.android.launcher3.AppsCustomizePagedView
|
||||
|
@ -60,13 +61,4 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
</LinearLayout>
|
||||
|
||||
<include
|
||||
android:id="@+id/market_button"
|
||||
layout="@layout/market_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="end"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</com.android.launcher3.AppsCustomizeTabHost>
|
||||
|
|
|
@ -214,7 +214,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||
int mWidgetLoadingId = -1;
|
||||
PendingAddWidgetInfo mCreateWidgetInfo = null;
|
||||
private boolean mDraggingWidget = false;
|
||||
boolean mPageBackgroundsVisible;
|
||||
boolean mPageBackgroundsVisible = true;
|
||||
|
||||
private Toast mWidgetInstructionToast;
|
||||
|
||||
|
@ -376,52 +376,19 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
|
||||
|
||||
final boolean hostIsTransitioning = getTabHost().isInTransition();
|
||||
|
||||
// Restore the page
|
||||
int page = getPageForComponent(mSaveInstanceStateItemIndex);
|
||||
invalidatePageData(Math.max(0, page), hostIsTransitioning);
|
||||
|
||||
// Show All Apps cling if we are finished transitioning, otherwise, we will try again when
|
||||
// the transition completes in AppsCustomizeTabHost (otherwise the wrong offsets will be
|
||||
// returned while animating)
|
||||
if (!hostIsTransitioning) {
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showAllAppsCling();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void showAllAppsCling() {
|
||||
if (!mHasShownAllAppsCling && isDataReady()) {
|
||||
mHasShownAllAppsCling = true;
|
||||
// Calculate the position for the cling punch through
|
||||
int[] offset = new int[2];
|
||||
int[] pos = mWidgetSpacingLayout.estimateCellPosition(mClingFocusedX, mClingFocusedY);
|
||||
mLauncher.getDragLayer().getLocationInDragLayer(this, offset);
|
||||
// PagedViews are centered horizontally but top aligned
|
||||
// Note we have to shift the items up now that Launcher sits under the status bar
|
||||
pos[0] += (getMeasuredWidth() - mWidgetSpacingLayout.getMeasuredWidth()) / 2 +
|
||||
offset[0];
|
||||
pos[1] += offset[1] - mLauncher.getDragLayer().getPaddingTop();
|
||||
}
|
||||
}
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int height = MeasureSpec.getSize(heightMeasureSpec);
|
||||
if (!isDataReady()) {
|
||||
if ((LauncherAppState.isDisableAllApps() || !mApps.isEmpty()) && !mWidgets.isEmpty()) {
|
||||
setDataIsReady();
|
||||
setMeasuredDimension(width, height);
|
||||
onDataReady(width, height);
|
||||
onDataReady(getMeasuredWidth(), getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
public void onPackagesUpdated(ArrayList<Object> widgetsAndShortcuts) {
|
||||
|
@ -1179,11 +1146,10 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
|
|||
|
||||
// Calculate the dimensions of each cell we are giving to each widget
|
||||
final ArrayList<Object> items = new ArrayList<Object>();
|
||||
int contentWidth = mContentWidth - getPaddingLeft() - getPaddingRight()
|
||||
- layout.getPaddingLeft() - layout.getPaddingRight();
|
||||
int contentWidth = mContentWidth - layout.getPaddingLeft() - layout.getPaddingRight();
|
||||
final int cellWidth = contentWidth / mWidgetCountX;
|
||||
int contentHeight = mContentHeight - getPaddingTop() - getPaddingBottom()
|
||||
- layout.getPaddingTop() - layout.getPaddingBottom();
|
||||
int contentHeight = mContentHeight - layout.getPaddingTop() - layout.getPaddingBottom();
|
||||
|
||||
final int cellHeight = contentHeight / mWidgetCountY;
|
||||
|
||||
// Prepare the set of widgets to load previews for in the background
|
||||
|
|
|
@ -57,16 +57,6 @@ class HotseatIconKeyEventListener implements View.OnKeyListener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A keyboard listener we set on the last tab button in AppsCustomize to jump to then
|
||||
* market icon and vice versa.
|
||||
*/
|
||||
class AppsCustomizeTabKeyEventListener implements View.OnKeyListener {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
return FocusHelper.handleAppsCustomizeTabKeyEvent(v, keyCode, event);
|
||||
}
|
||||
}
|
||||
|
||||
public class FocusHelper {
|
||||
/**
|
||||
* Private helper to get the parent TabHost in the view hiearchy.
|
||||
|
@ -79,41 +69,6 @@ public class FocusHelper {
|
|||
return (AppsCustomizeTabHost) p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles key events in a AppsCustomize tab between the last tab view and the shop button.
|
||||
*/
|
||||
static boolean handleAppsCustomizeTabKeyEvent(View v, int keyCode, KeyEvent e) {
|
||||
final AppsCustomizeTabHost tabHost = findTabHostParent(v);
|
||||
final ViewGroup contents = tabHost.getContent();
|
||||
final View shop = tabHost.findViewById(R.id.market_button);
|
||||
|
||||
final int action = e.getAction();
|
||||
final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
|
||||
boolean wasHandled = false;
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
if (handleKeyEvent) {
|
||||
// Select the shop button if we aren't on it
|
||||
if (v != shop) {
|
||||
shop.requestFocus();
|
||||
}
|
||||
}
|
||||
wasHandled = true;
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||
if (handleKeyEvent) {
|
||||
// Select the content view (down is handled by the tab key handler otherwise)
|
||||
if (v == shop) {
|
||||
contents.requestFocus();
|
||||
wasHandled = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return wasHandled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Viewgroup containing page contents for the page at the index specified.
|
||||
*/
|
||||
|
|
|
@ -329,10 +329,6 @@ public class Launcher extends Activity
|
|||
// External icons saved in case of resource changes, orientation, etc.
|
||||
private static Drawable.ConstantState[] sGlobalSearchIcon = new Drawable.ConstantState[2];
|
||||
private static Drawable.ConstantState[] sVoiceSearchIcon = new Drawable.ConstantState[2];
|
||||
private static Drawable.ConstantState[] sAppMarketIcon = new Drawable.ConstantState[2];
|
||||
|
||||
private Intent mAppMarketIntent = null;
|
||||
private static final boolean DISABLE_MARKET_BUTTON = true;
|
||||
|
||||
private Drawable mWorkspaceBackgroundDrawable;
|
||||
|
||||
|
@ -557,11 +553,7 @@ public class Launcher extends Activity
|
|||
boolean voiceVisible = false;
|
||||
// If we have a saved version of these external icons, we load them up immediately
|
||||
int coi = getCurrentOrientationIndexForGlobalIcons();
|
||||
if (sGlobalSearchIcon[coi] == null || sVoiceSearchIcon[coi] == null ||
|
||||
sAppMarketIcon[coi] == null) {
|
||||
if (!DISABLE_MARKET_BUTTON) {
|
||||
updateAppMarketIcon();
|
||||
}
|
||||
if (sGlobalSearchIcon[coi] == null || sVoiceSearchIcon[coi] == null) {
|
||||
searchVisible = updateGlobalSearchIcon();
|
||||
voiceVisible = updateVoiceSearchIcon(searchVisible);
|
||||
}
|
||||
|
@ -573,9 +565,6 @@ public class Launcher extends Activity
|
|||
updateVoiceSearchIcon(sVoiceSearchIcon[coi]);
|
||||
voiceVisible = true;
|
||||
}
|
||||
if (!DISABLE_MARKET_BUTTON && sAppMarketIcon[coi] != null) {
|
||||
updateAppMarketIcon(sAppMarketIcon[coi]);
|
||||
}
|
||||
if (mSearchDropTargetBar != null) {
|
||||
mSearchDropTargetBar.onSearchPackagesChanged(searchVisible, voiceVisible);
|
||||
}
|
||||
|
@ -1753,11 +1742,6 @@ public class Launcher extends Activity
|
|||
}
|
||||
});
|
||||
}
|
||||
// When Launcher comes back to foreground, a different Activity might be responsible for
|
||||
// the app market intent, so refresh the icon
|
||||
if (!DISABLE_MARKET_BUTTON) {
|
||||
updateAppMarketIcon();
|
||||
}
|
||||
clearTypedText();
|
||||
}
|
||||
}
|
||||
|
@ -2739,16 +2723,6 @@ public class Launcher extends Activity
|
|||
return mHapticFeedbackTouchListener;
|
||||
}
|
||||
|
||||
public void onClickAppMarketButton(View v) {
|
||||
if (!DISABLE_MARKET_BUTTON) {
|
||||
if (mAppMarketIntent != null) {
|
||||
startActivitySafely(v, mAppMarketIntent, "app market");
|
||||
} else {
|
||||
Log.e(TAG, "Invalid app market intent.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onDragStarted(View view) {}
|
||||
|
||||
/**
|
||||
|
@ -4008,44 +3982,6 @@ public class Launcher extends Activity
|
|||
public void disableVoiceButtonProxy(boolean disabled) {
|
||||
updateVoiceButtonProxyVisible(disabled);
|
||||
}
|
||||
/**
|
||||
* Sets the app market icon
|
||||
*/
|
||||
private void updateAppMarketIcon() {
|
||||
if (!DISABLE_MARKET_BUTTON) {
|
||||
final View marketButton = findViewById(R.id.market_button);
|
||||
Intent intent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_APP_MARKET);
|
||||
// Find the app market activity by resolving an intent.
|
||||
// (If multiple app markets are installed, it will return the ResolverActivity.)
|
||||
ComponentName activityName = intent.resolveActivity(getPackageManager());
|
||||
if (activityName != null) {
|
||||
int coi = getCurrentOrientationIndexForGlobalIcons();
|
||||
mAppMarketIntent = intent;
|
||||
sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity(
|
||||
R.id.market_button, activityName, R.drawable.ic_launcher_market_holo,
|
||||
TOOLBAR_ICON_METADATA_NAME);
|
||||
marketButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
// We should hide and disable the view so that we don't try and restore the visibility
|
||||
// of it when we swap between drag & normal states from IconDropTarget subclasses.
|
||||
marketButton.setVisibility(View.GONE);
|
||||
marketButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAppMarketIcon(Drawable.ConstantState d) {
|
||||
if (!DISABLE_MARKET_BUTTON) {
|
||||
// Ensure that the new drawable we are creating has the approprate toolbar icon bounds
|
||||
Resources r = getResources();
|
||||
Drawable marketIconDrawable = d.newDrawable(r);
|
||||
int w = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_width);
|
||||
int h = r.getDimensionPixelSize(R.dimen.toolbar_external_icon_height);
|
||||
marketIconDrawable.setBounds(0, 0, w, h);
|
||||
|
||||
updateTextButtonWithDrawable(R.id.market_button, marketIconDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
|
@ -4553,12 +4489,6 @@ public class Launcher extends Activity
|
|||
|
||||
mWorkspace.restoreInstanceStateForRemainingPages();
|
||||
|
||||
// Update the market app icon as necessary (the other icons will be managed in response to
|
||||
// package changes in bindSearchablesChanged()
|
||||
if (!DISABLE_MARKET_BUTTON) {
|
||||
updateAppMarketIcon();
|
||||
}
|
||||
|
||||
setWorkspaceLoading(false);
|
||||
sendLoadingCompleteBroadcastIfNecessary();
|
||||
|
||||
|
|