summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNebojsa Cvetkovic <nebkat@gmail.com>2013-12-09 18:32:38 +0000
committerDanesh M <daneshm90@gmail.com>2014-01-24 16:24:24 -0800
commit3cf0c6dd7a82713fc14304632dec86c002d83821 (patch)
tree063ed8367eaf3765e43beac8bfeacf8d903b3746
parentd04d02edd24c9eff4d51b3436922414c0db36220 (diff)
downloadandroid_packages_apps_Trebuchet-3cf0c6dd7a82713fc14304632dec86c002d83821.tar.gz
android_packages_apps_Trebuchet-3cf0c6dd7a82713fc14304632dec86c002d83821.tar.bz2
android_packages_apps_Trebuchet-3cf0c6dd7a82713fc14304632dec86c002d83821.zip
AppsCustomize: Remove tabs
Change-Id: I8c3b146b4f3a60f28b9bce16c37e57696cbe2944
-rw-r--r--protos/com/android/launcher3/backup/BackupProtos.java (renamed from protos/org/cyanogenmod/trebuchet/backup/BackupProtos.java)24
-rw-r--r--res/layout/apps_customize_pane.xml85
-rw-r--r--src/com/android/launcher3/AppsCustomizeLayout.java235
-rw-r--r--src/com/android/launcher3/AppsCustomizePagedView.java16
-rw-r--r--src/com/android/launcher3/FocusHelper.java117
-rw-r--r--src/com/android/launcher3/HideFromAccessibilityHelper.java2
-rw-r--r--src/com/android/launcher3/Launcher.java135
7 files changed, 310 insertions, 304 deletions
diff --git a/protos/org/cyanogenmod/trebuchet/backup/BackupProtos.java b/protos/com/android/launcher3/backup/BackupProtos.java
index 639163bd7..754930ceb 100644
--- a/protos/org/cyanogenmod/trebuchet/backup/BackupProtos.java
+++ b/protos/com/android/launcher3/backup/BackupProtos.java
@@ -1,5 +1,5 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
-package org.cyanogenmod.trebuchet.backup;
+package com.android.launcher3.backup;
import com.google.protobuf.nano.MessageNano;
@@ -238,14 +238,14 @@ public final class BackupProtos {
public int rows = 0;
// repeated .launcher_backup.Key key = 5;
- public org.cyanogenmod.trebuchet.backup.BackupProtos.Key[] key = org.cyanogenmod.trebuchet.backup.BackupProtos.Key.EMPTY_ARRAY;
+ public com.android.launcher3.backup.BackupProtos.Key[] key = com.android.launcher3.backup.BackupProtos.Key.EMPTY_ARRAY;
public final Journal clear() {
appVersion = 0;
t = 0L;
bytes = 0L;
rows = 0;
- key = org.cyanogenmod.trebuchet.backup.BackupProtos.Key.EMPTY_ARRAY;
+ key = com.android.launcher3.backup.BackupProtos.Key.EMPTY_ARRAY;
cachedSize = -1;
return this;
}
@@ -261,7 +261,7 @@ public final class BackupProtos {
if (this.rows != 0) {
output.writeInt32(4, this.rows);
}
- for (org.cyanogenmod.trebuchet.backup.BackupProtos.Key element : this.key) {
+ for (com.android.launcher3.backup.BackupProtos.Key element : this.key) {
output.writeMessage(5, element);
}
}
@@ -291,7 +291,7 @@ public final class BackupProtos {
size += com.google.protobuf.nano.CodedOutputByteBufferNano
.computeInt32Size(4, this.rows);
}
- for (org.cyanogenmod.trebuchet.backup.BackupProtos.Key element : this.key) {
+ for (com.android.launcher3.backup.BackupProtos.Key element : this.key) {
size += com.google.protobuf.nano.CodedOutputByteBufferNano
.computeMessageSize(5, element);
}
@@ -333,16 +333,16 @@ public final class BackupProtos {
case 42: {
int arrayLength = com.google.protobuf.nano.WireFormatNano.getRepeatedFieldArrayLength(input, 42);
int i = this.key.length;
- org.cyanogenmod.trebuchet.backup.BackupProtos.Key[] newArray = new org.cyanogenmod.trebuchet.backup.BackupProtos.Key[i + arrayLength];
+ com.android.launcher3.backup.BackupProtos.Key[] newArray = new com.android.launcher3.backup.BackupProtos.Key[i + arrayLength];
System.arraycopy(this.key, 0, newArray, 0, i);
this.key = newArray;
for (; i < this.key.length - 1; i++) {
- this.key[i] = new org.cyanogenmod.trebuchet.backup.BackupProtos.Key();
+ this.key[i] = new com.android.launcher3.backup.BackupProtos.Key();
input.readMessage(this.key[i]);
input.readTag();
}
// Last one without readTag.
- this.key[i] = new org.cyanogenmod.trebuchet.backup.BackupProtos.Key();
+ this.key[i] = new com.android.launcher3.backup.BackupProtos.Key();
input.readMessage(this.key[i]);
break;
}
@@ -884,10 +884,10 @@ public final class BackupProtos {
public boolean configure = false;
// optional .launcher_backup.Resource icon = 4;
- public org.cyanogenmod.trebuchet.backup.BackupProtos.Resource icon = null;
+ public com.android.launcher3.backup.BackupProtos.Resource icon = null;
// optional .launcher_backup.Resource preview = 5;
- public org.cyanogenmod.trebuchet.backup.BackupProtos.Resource preview = null;
+ public com.android.launcher3.backup.BackupProtos.Resource preview = null;
public final Widget clear() {
provider = "";
@@ -980,12 +980,12 @@ public final class BackupProtos {
break;
}
case 34: {
- this.icon = new org.cyanogenmod.trebuchet.backup.BackupProtos.Resource();
+ this.icon = new com.android.launcher3.backup.BackupProtos.Resource();
input.readMessage(this.icon);
break;
}
case 42: {
- this.preview = new org.cyanogenmod.trebuchet.backup.BackupProtos.Resource();
+ this.preview = new com.android.launcher3.backup.BackupProtos.Resource();
input.readMessage(this.preview);
break;
}
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index 11a938fbb..fbcd9f6c3 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -13,69 +13,34 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<com.android.launcher3.AppsCustomizeTabHost
+<com.android.launcher3.AppsCustomizeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
- android:background="#80FFFFFF">
- <LinearLayout
+ xmlns:launcher="http://schemas.android.com/apk/res-auto"
+ android:background="#80FFFFFF"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <FrameLayout
android:id="@+id/apps_customize_content"
- android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
- <!-- 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/apps_customize_tab_bar_height"
- android:layout_marginTop="@dimen/apps_customize_tab_bar_margin_top"
- android:layout_gravity="center_horizontal"
- android:visibility="gone">
- <com.android.launcher3.FocusOnlyTabWidget
- android:id="@android:id/tabs"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:gravity="start"
- android:background="@drawable/tab_unselected_holo"
- android:tabStripEnabled="false"
- android:divider="@null" />
- <include
- android:id="@+id/market_button"
- layout="@layout/market_button"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="end" />
- </FrameLayout>
- <FrameLayout
- android:id="@android:id/tabcontent"
+ <com.android.launcher3.AppsCustomizePagedView
+ android:id="@+id/apps_customize_pane_content"
android:layout_width="match_parent"
- android:layout_height="match_parent">
- <com.android.launcher3.AppsCustomizePagedView
- android:id="@+id/apps_customize_pane_content"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginBottom="@dimen/apps_customize_page_indicator_offset"
- launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
- launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
- launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
- launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
- launcher:maxGap="@dimen/workspace_max_gap"
- launcher:pageIndicator="@+id/page_indicator" />
- <FrameLayout
- android:id="@+id/animation_buffer"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="#FF000000"
- android:visibility="gone" />
- <include
- android:id="@+id/page_indicator"
- layout="@layout/page_indicator"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom|center_horizontal"
- android:layout_marginBottom="@dimen/apps_customize_page_indicator_margin" />
- </FrameLayout>
- </LinearLayout>
-</com.android.launcher3.AppsCustomizeTabHost>
+ android:layout_height="match_parent"
+ android:layout_marginBottom="@dimen/apps_customize_page_indicator_offset"
+ launcher:widgetCountX="@integer/apps_customize_widget_cell_count_x"
+ launcher:widgetCountY="@integer/apps_customize_widget_cell_count_y"
+ launcher:clingFocusedX="@integer/apps_customize_cling_focused_x"
+ launcher:clingFocusedY="@integer/apps_customize_cling_focused_y"
+ launcher:maxGap="@dimen/workspace_max_gap"
+ launcher:pageIndicator="@+id/page_indicator" />
+ <include
+ android:id="@+id/page_indicator"
+ layout="@layout/page_indicator"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|center_horizontal"
+ android:layout_marginBottom="@dimen/apps_customize_page_indicator_margin" />
+ </FrameLayout>
+</com.android.launcher3.AppsCustomizeLayout>
diff --git a/src/com/android/launcher3/AppsCustomizeLayout.java b/src/com/android/launcher3/AppsCustomizeLayout.java
new file mode 100644
index 000000000..09879dc25
--- /dev/null
+++ b/src/com/android/launcher3/AppsCustomizeLayout.java
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+package com.android.launcher3;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
+public class AppsCustomizeLayout extends FrameLayout implements LauncherTransitionable,
+ Insettable {
+ private AppsCustomizePagedView mAppsCustomizePane;
+ private FrameLayout mContent;
+
+ private boolean mInTransition;
+ private boolean mTransitioningToWorkspace;
+ private boolean mResetAfterTransition;
+ private final Rect mInsets = new Rect();
+
+ public AppsCustomizeLayout(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Override
+ public void setInsets(Rect insets) {
+ mInsets.set(insets);
+ FrameLayout.LayoutParams flp = (LayoutParams) mContent.getLayoutParams();
+ flp.topMargin = insets.top;
+ flp.bottomMargin = insets.bottom;
+ flp.leftMargin = insets.left;
+ flp.rightMargin = insets.right;
+ mContent.setLayoutParams(flp);
+ }
+
+ /**
+ * Setup the tab host and create all necessary tabs.
+ */
+ @Override
+ protected void onFinishInflate() {
+ final AppsCustomizePagedView appsCustomizePane = (AppsCustomizePagedView)
+ findViewById(R.id.apps_customize_pane_content);
+ mAppsCustomizePane = appsCustomizePane;
+ mContent = (FrameLayout) findViewById(R.id.apps_customize_content);
+ if (mAppsCustomizePane == null) throw new Resources.NotFoundException();
+
+ }
+
+ public boolean onInterceptTouchEvent(MotionEvent ev) {
+ // If we are mid transitioning to the workspace, then intercept touch events here so we
+ // can ignore them, otherwise we just let all apps handle the touch events.
+ if (mInTransition && mTransitioningToWorkspace) {
+ return true;
+ }
+ return super.onInterceptTouchEvent(ev);
+ };
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ // Allow touch events to fall through to the workspace if we are transitioning there
+ if (mInTransition && mTransitioningToWorkspace) {
+ return super.onTouchEvent(event);
+ }
+
+ // Intercept all touch events up to the bottom of the AppsCustomizePane so they do not fall
+ // through to the workspace and trigger showWorkspace()
+ if (event.getY() < mAppsCustomizePane.getBottom()) {
+ return true;
+ }
+ return super.onTouchEvent(event);
+ }
+
+ /**
+ * Disable focus on anything under this view in the hierarchy if we are not visible.
+ */
+ @Override
+ public int getDescendantFocusability() {
+ if (getVisibility() != View.VISIBLE) {
+ return ViewGroup.FOCUS_BLOCK_DESCENDANTS;
+ }
+ return super.getDescendantFocusability();
+ }
+
+ void reset() {
+ if (mInTransition) {
+ // Defer to after the transition to reset
+ mResetAfterTransition = true;
+ } else {
+ // Reset immediately
+ mAppsCustomizePane.reset();
+ }
+ }
+
+ private void enableAndBuildHardwareLayer() {
+ // isHardwareAccelerated() checks if we're attached to a window and if that
+ // window is HW accelerated-- we were sometimes not attached to a window
+ // and buildLayer was throwing an IllegalStateException
+ if (isHardwareAccelerated()) {
+ // Turn on hardware layers for performance
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+
+ // force building the layer, so you don't get a blip early in an animation
+ // when the layer is created layer
+ buildLayer();
+ }
+ }
+
+ @Override
+ public View getContent() {
+ return mContent;
+ }
+
+ /* LauncherTransitionable overrides */
+ @Override
+ public void onLauncherTransitionPrepare(Launcher l, boolean animated, boolean toWorkspace) {
+ mAppsCustomizePane.onLauncherTransitionPrepare(l, animated, toWorkspace);
+ mInTransition = true;
+ mTransitioningToWorkspace = toWorkspace;
+
+ if (toWorkspace) {
+ // Going from All Apps -> Workspace
+ setVisibilityOfSiblingsWithLowerZOrder(VISIBLE);
+ } else {
+ // Going from Workspace -> All Apps
+ mContent.setVisibility(VISIBLE);
+
+ // Make sure the current page is loaded (we start loading the side pages after the
+ // transition to prevent slowing down the animation)
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
+ }
+
+ if (mResetAfterTransition) {
+ mAppsCustomizePane.reset();
+ mResetAfterTransition = false;
+ }
+ }
+
+ @Override
+ public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
+ if (animated) {
+ enableAndBuildHardwareLayer();
+ }
+
+ // Dismiss the workspace cling
+ l.dismissWorkspaceCling(null);
+ }
+
+ @Override
+ public void onLauncherTransitionStep(Launcher l, float t) {
+ // Do nothing
+ }
+
+ @Override
+ public void onLauncherTransitionEnd(Launcher l, boolean animated, boolean toWorkspace) {
+ mAppsCustomizePane.onLauncherTransitionEnd(l, animated, toWorkspace);
+ mInTransition = false;
+ if (animated) {
+ setLayerType(LAYER_TYPE_NONE, null);
+ }
+
+ if (!toWorkspace) {
+ // Show the all apps cling (if not already shown)
+ mAppsCustomizePane.showAllAppsCling();
+ // Make sure adjacent pages are loaded (we wait until after the transition to
+ // prevent slowing down the animation)
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
+
+ // Going from Workspace -> All Apps
+ // NOTE: We should do this at the end since we check visibility state in some of the
+ // cling initialization/dismiss code above.
+ setVisibilityOfSiblingsWithLowerZOrder(INVISIBLE);
+ }
+ }
+
+ private void setVisibilityOfSiblingsWithLowerZOrder(int visibility) {
+ ViewGroup parent = (ViewGroup) getParent();
+ if (parent == null) return;
+
+ View overviewPanel = ((Launcher) getContext()).getOverviewPanel();
+ final int count = parent.getChildCount();
+ if (!isChildrenDrawingOrderEnabled()) {
+ for (int i = 0; i < count; i++) {
+ final View child = parent.getChildAt(i);
+ if (child == this) {
+ break;
+ } else {
+ if (child.getVisibility() == GONE || child == overviewPanel) {
+ continue;
+ }
+ child.setVisibility(visibility);
+ }
+ }
+ } else {
+ throw new RuntimeException("Failed; can't get z-order of views");
+ }
+ }
+
+ public void onWindowVisible() {
+ if (getVisibility() == VISIBLE) {
+ mContent.setVisibility(VISIBLE);
+ // We unload the widget previews when the UI is hidden, so need to reload pages
+ // Load the current page synchronously, and the neighboring pages asynchronously
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
+ mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
+ }
+ }
+
+ public void onTrimMemory() {
+ mContent.setVisibility(GONE);
+ // Clear the widget pages of all their subviews - this will trigger the widget previews
+ // to delete their bitmaps
+ mAppsCustomizePane.clearAllWidgetPages();
+ }
+
+ boolean isTransitioning() {
+ return mInTransition;
+ }
+}
diff --git a/src/com/android/launcher3/AppsCustomizePagedView.java b/src/com/android/launcher3/AppsCustomizePagedView.java
index 9b35bb5ea..ace83f77e 100644
--- a/src/com/android/launcher3/AppsCustomizePagedView.java
+++ b/src/com/android/launcher3/AppsCustomizePagedView.java
@@ -379,7 +379,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
int heightSpec = MeasureSpec.makeMeasureSpec(mContentHeight, MeasureSpec.AT_MOST);
mWidgetSpacingLayout.measure(widthSpec, heightSpec);
- AppsCustomizeTabHost host = (AppsCustomizeTabHost) getTabHost();
+ AppsCustomizeLayout host = (AppsCustomizeLayout) getLayout();
final boolean hostIsTransitioning = host.isTransitioning();
// Restore the page
@@ -387,7 +387,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
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
+ // the transition completes in AppsCustomizeLayout (otherwise the wrong offsets will be
// returned while animating)
if (!hostIsTransitioning) {
post(new Runnable() {
@@ -1587,21 +1587,13 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
// If we have reset, then we should not continue to restore the previous state
mSaveInstanceStateItemIndex = -1;
- AppsCustomizeTabHost tabHost = getTabHost();
- String tag = tabHost.getCurrentTabTag();
- if (tag != null) {
- if (!tag.equals(tabHost.getTabTagForContentType(ContentType.Applications))) {
- tabHost.setCurrentTabFromContent(ContentType.Applications);
- }
- }
-
if (mCurrentPage != 0) {
invalidatePageData(0);
}
}
- private AppsCustomizeTabHost getTabHost() {
- return (AppsCustomizeTabHost) mLauncher.findViewById(R.id.apps_customize_pane);
+ private AppsCustomizeLayout getLayout() {
+ return (AppsCustomizeLayout) mLauncher.findViewById(R.id.apps_customize_pane);
}
public void dumpState() {
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index 4600985c4..357af49f6 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -57,62 +57,7 @@ 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.
- */
- private static TabHost findTabHostParent(View v) {
- ViewParent p = v.getParent();
- while (p != null && !(p instanceof TabHost)) {
- p = p.getParent();
- }
- return (TabHost) 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 TabHost tabHost = findTabHostParent(v);
- final ViewGroup contents = tabHost.getTabContentView();
- 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.
@@ -134,8 +79,6 @@ public class FocusHelper {
final PagedViewGridLayout parent = (PagedViewGridLayout) w.getParent();
final PagedView container = (PagedView) parent.getParent();
- final TabHost tabHost = findTabHostParent(container);
- final TabWidget tabs = tabHost.getTabWidget();
final int widgetIndex = parent.indexOfChild(w);
final int widgetCount = parent.getChildCount();
final int pageIndex = ((PagedView) container).indexToPage(container.indexOfChild(parent));
@@ -194,8 +137,6 @@ public class FocusHelper {
int newWidgetIndex = ((y - 1) * cellCountX) + x;
child = parent.getChildAt(newWidgetIndex);
if (child != null) child.requestFocus();
- } else {
- tabs.requestFocus();
}
}
wasHandled = true;
@@ -294,8 +235,6 @@ public class FocusHelper {
// Note we have an extra parent because of the
// PagedViewCellLayout/PagedViewCellLayoutChildren relationship
final PagedView container = (PagedView) parentLayout.getParent();
- final TabHost tabHost = findTabHostParent(container);
- final TabWidget tabs = tabHost.getTabWidget();
final int iconIndex = itemContainer.indexOfChild(v);
final int itemCount = itemContainer.getChildCount();
final int pageIndex = ((PagedView) container).indexToPage(container.indexOfChild(parentLayout));
@@ -354,8 +293,6 @@ public class FocusHelper {
if (y > 0) {
int newiconIndex = ((y - 1) * countX) + x;
itemContainer.getChildAt(newiconIndex).requestFocus();
- } else {
- tabs.requestFocus();
}
}
wasHandled = true;
@@ -433,60 +370,6 @@ public class FocusHelper {
}
/**
- * Handles key events in the tab widget.
- */
- static boolean handleTabKeyEvent(AccessibleTabView v, int keyCode, KeyEvent e) {
- if (!LauncherAppState.getInstance().isScreenLarge()) return false;
-
- final FocusOnlyTabWidget parent = (FocusOnlyTabWidget) v.getParent();
- final TabHost tabHost = findTabHostParent(parent);
- final ViewGroup contents = tabHost.getTabContentView();
- final int tabCount = parent.getTabCount();
- final int tabIndex = parent.getChildTabIndex(v);
-
- final int action = e.getAction();
- final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP);
- boolean wasHandled = false;
- switch (keyCode) {
- case KeyEvent.KEYCODE_DPAD_LEFT:
- if (handleKeyEvent) {
- // Select the previous tab
- if (tabIndex > 0) {
- parent.getChildTabViewAt(tabIndex - 1).requestFocus();
- }
- }
- wasHandled = true;
- break;
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (handleKeyEvent) {
- // Select the next tab, or if the last tab has a focus right id, select that
- if (tabIndex < (tabCount - 1)) {
- parent.getChildTabViewAt(tabIndex + 1).requestFocus();
- } else {
- if (v.getNextFocusRightId() != View.NO_ID) {
- tabHost.findViewById(v.getNextFocusRightId()).requestFocus();
- }
- }
- }
- wasHandled = true;
- break;
- case KeyEvent.KEYCODE_DPAD_UP:
- // Do nothing
- wasHandled = true;
- break;
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (handleKeyEvent) {
- // Select the content view
- contents.requestFocus();
- }
- wasHandled = true;
- break;
- default: break;
- }
- return wasHandled;
- }
-
- /**
* Handles key events in the workspace hotseat (bottom of the screen).
*/
static boolean handleHotseatButtonKeyEvent(View v, int keyCode, KeyEvent e, int orientation) {
diff --git a/src/com/android/launcher3/HideFromAccessibilityHelper.java b/src/com/android/launcher3/HideFromAccessibilityHelper.java
index 75cbb1b1e..7b22190a9 100644
--- a/src/com/android/launcher3/HideFromAccessibilityHelper.java
+++ b/src/com/android/launcher3/HideFromAccessibilityHelper.java
@@ -102,7 +102,7 @@ public class HideFromAccessibilityHelper implements OnHierarchyChangeListener {
private boolean includeView(View v) {
return !hasAncestorOfType(v, Cling.class) &&
- (!mOnlyAllApps || hasAncestorOfType(v, AppsCustomizeTabHost.class));
+ (!mOnlyAllApps || hasAncestorOfType(v, AppsCustomizeLayout.class));
}
private boolean hasAncestorOfType(View v, Class c) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index c88f1e561..79e0b5d83 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -240,7 +240,7 @@ public class Launcher extends Activity
private View mAllAppsButton;
private SearchDropTargetBar mSearchDropTargetBar;
- private AppsCustomizeTabHost mAppsCustomizeTabHost;
+ private AppsCustomizeLayout mAppsCustomizeLayout;
private AppsCustomizePagedView mAppsCustomizeContent;
private boolean mAutoAdvanceRunning = false;
private View mQsbBar;
@@ -299,10 +299,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;
@@ -518,11 +514,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);
}
@@ -534,9 +526,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);
}
@@ -1128,11 +1117,10 @@ public class Launcher extends Activity
}
// Restore the AppsCustomize tab
- if (mAppsCustomizeTabHost != null) {
- String curTab = savedState.getString("apps_customize_currentTab");
- if (curTab != null) {
- mAppsCustomizeTabHost.setContentTypeImmediate(
- mAppsCustomizeTabHost.getContentTypeForTabTag(curTab));
+ if (mAppsCustomizeLayout != null) {
+ String curContentType = savedState.getString("apps_customize_currentContentType");
+ if (curContentType != null) {
+ mAppsCustomizeContent.setContentType(AppsCustomizePagedView.ContentType.valueOf(curContentType));
mAppsCustomizeContent.loadAssociatedPages(
mAppsCustomizeContent.getCurrentPage());
}
@@ -1214,9 +1202,9 @@ public class Launcher extends Activity
mSearchDropTargetBar = (SearchDropTargetBar) mDragLayer.findViewById(R.id.qsb_bar);
// Setup AppsCustomize
- mAppsCustomizeTabHost = (AppsCustomizeTabHost) findViewById(R.id.apps_customize_pane);
+ mAppsCustomizeLayout = (AppsCustomizeLayout) findViewById(R.id.apps_customize_pane);
mAppsCustomizeContent = (AppsCustomizePagedView)
- mAppsCustomizeTabHost.findViewById(R.id.apps_customize_pane_content);
+ mAppsCustomizeLayout.findViewById(R.id.apps_customize_pane_content);
mAppsCustomizeContent.setup(this, dragController);
// Setup the drag controller (drop targets have to be added in reverse order in priority)
@@ -1490,7 +1478,7 @@ public class Launcher extends Activity
// Reset AllApps to its initial state only if we are not in the middle of
// processing a multi-step drop
- if (mAppsCustomizeTabHost != null && mPendingAddInfo.container == ItemInfo.NO_ID) {
+ if (mAppsCustomizeLayout != null && mPendingAddInfo.container == ItemInfo.NO_ID) {
showWorkspace(false);
}
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
@@ -1533,7 +1521,7 @@ public class Launcher extends Activity
// you're in All Apps and click home to go to the workspace. onWindowVisibilityChanged
// is a more appropriate event to handle
if (mVisible) {
- mAppsCustomizeTabHost.onWindowVisible();
+ mAppsCustomizeLayout.onWindowVisible();
if (!mWorkspaceLoading) {
final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
// We want to let Launcher draw itself at least once before we force it to build
@@ -1541,6 +1529,7 @@ public class Launcher extends Activity
// apps is nice and speedy.
observer.addOnDrawListener(new ViewTreeObserver.OnDrawListener() {
private boolean mStarted = false;
+
public void onDraw() {
if (mStarted) return;
mStarted = true;
@@ -1552,23 +1541,18 @@ public class Launcher extends Activity
mWorkspace.postDelayed(mBuildLayersRunnable, 500);
final ViewTreeObserver.OnDrawListener listener = this;
mWorkspace.post(new Runnable() {
- public void run() {
- if (mWorkspace != null &&
- mWorkspace.getViewTreeObserver() != null) {
- mWorkspace.getViewTreeObserver().
- removeOnDrawListener(listener);
- }
+ public void run() {
+ if (mWorkspace != null &&
+ mWorkspace.getViewTreeObserver() != null) {
+ mWorkspace.getViewTreeObserver().
+ removeOnDrawListener(listener);
}
- });
+ }
+ });
return;
}
});
}
- // 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();
}
}
@@ -1710,8 +1694,8 @@ public class Launcher extends Activity
}
// Reset the apps customize page
- if (mAppsCustomizeTabHost != null) {
- mAppsCustomizeTabHost.reset();
+ if (mAppsCustomizeLayout != null) {
+ mAppsCustomizeLayout.reset();
}
}
@@ -1757,10 +1741,10 @@ public class Launcher extends Activity
}
// Save the current AppsCustomize tab
- if (mAppsCustomizeTabHost != null) {
- String currentTabTag = mAppsCustomizeTabHost.getCurrentTabTag();
+ if (mAppsCustomizeLayout != null) {
+ String currentTabTag = mAppsCustomizeContent.getContentType().name();
if (currentTabTag != null) {
- outState.putString("apps_customize_currentTab", currentTabTag);
+ outState.putString("apps_customize_currentContentType", currentTabTag);
}
int currentIndex = mAppsCustomizeContent.getSaveInstanceStateIndex();
outState.putInt("apps_customize_currentIndex", currentIndex);
@@ -2317,16 +2301,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.");
- }
- }
- }
-
/**
* Called when the user stops interacting with the launcher.
* This implies that the user is now on the homescreen and is not doing housekeeping.
@@ -2813,7 +2787,7 @@ public class Launcher extends Activity
final int fadeDuration = res.getInteger(R.integer.config_appsCustomizeFadeInTime);
final float scale = (float) res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
final View fromView = mWorkspace;
- final AppsCustomizeTabHost toView = mAppsCustomizeTabHost;
+ final AppsCustomizeLayout toView = mAppsCustomizeLayout;
final int startDelay =
res.getInteger(R.integer.config_workspaceAppsCustomizeAnimationStagger);
@@ -2824,7 +2798,7 @@ public class Launcher extends Activity
mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated);
if (!AppsCustomizePagedView.DISABLE_ALL_APPS) {
// Set the content type for the all apps space
- mAppsCustomizeTabHost.setContentTypeImmediate(contentType);
+ mAppsCustomizeContent.setContentType(contentType);
}
if (animated) {
@@ -2869,6 +2843,7 @@ public class Launcher extends Activity
toView.setVisibility(View.VISIBLE);
toView.bringToFront();
}
+
@Override
public void onAnimationEnd(Animator animation) {
dispatchOnLauncherTransitionEnd(fromView, animated, false);
@@ -2965,7 +2940,7 @@ public class Launcher extends Activity
res.getInteger(R.integer.config_appsCustomizeFadeOutTime);
final float scaleFactor = (float)
res.getInteger(R.integer.config_appsCustomizeZoomScaleFactor);
- final View fromView = mAppsCustomizeTabHost;
+ final View fromView = mAppsCustomizeLayout;
final View toView = mWorkspace;
Animator workspaceAnim = null;
if (toState == Workspace.State.NORMAL) {
@@ -3043,7 +3018,7 @@ public class Launcher extends Activity
public void onTrimMemory(int level) {
super.onTrimMemory(level);
if (level >= ComponentCallbacks2.TRIM_MEMORY_MODERATE) {
- mAppsCustomizeTabHost.onTrimMemory();
+ mAppsCustomizeLayout.onTrimMemory();
}
}
@@ -3105,10 +3080,10 @@ public class Launcher extends Activity
if (mState != State.WORKSPACE) return;
if (resetPageToZero) {
- mAppsCustomizeTabHost.reset();
+ mAppsCustomizeLayout.reset();
}
showAppsCustomizeHelper(animated, false, contentType);
- mAppsCustomizeTabHost.requestFocus();
+ mAppsCustomizeLayout.requestFocus();
// Change the state *after* we've called all the transition code
mState = State.APPS_CUSTOMIZE;
@@ -3141,7 +3116,7 @@ public class Launcher extends Activity
// Before we show workspace, hide all apps again because
// exitSpringLoadedDragMode made it visible. This is a bit hacky; we should
// clean up our state transition functions
- mAppsCustomizeTabHost.setVisibility(View.GONE);
+ mAppsCustomizeLayout.setVisibility(View.GONE);
showWorkspace(true, onCompleteRunnable);
} else {
exitSpringLoadedDragMode();
@@ -3442,44 +3417,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) {
@@ -3487,8 +3424,8 @@ public class Launcher extends Activity
final List<CharSequence> text = event.getText();
text.clear();
// Populate event with a fake title based on the current state.
- if (mState == State.APPS_CUSTOMIZE) {
- text.add(mAppsCustomizeTabHost.getCurrentTabView().getContentDescription());
+ if (mState != State.APPS_CUSTOMIZE) {
+ text.add(getString(R.string.all_apps_button_label));
} else {
text.add(getString(R.string.all_apps_home_button_label));
}
@@ -3889,12 +3826,6 @@ public class Launcher extends Activity
}
sPendingAddList.clear();
- // 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();
- }
-
mWorkspaceLoading = false;
if (upgradePath) {
mWorkspace.getUniqueComponents(true, null);