Merge "Updated launcher assets." into jb-ub-now-indigo-rose
diff --git a/res/drawable-hdpi/ic_gel_setting_icn.png b/res/drawable-hdpi/ic_gel_setting_icn.png
new file mode 100644
index 0000000..f805947
--- /dev/null
+++ b/res/drawable-hdpi/ic_gel_setting_icn.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_gel_wallpaper_icn.png b/res/drawable-hdpi/ic_gel_wallpaper_icn.png
new file mode 100644
index 0000000..ad13c85
--- /dev/null
+++ b/res/drawable-hdpi/ic_gel_wallpaper_icn.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_gel_widget_icn.png b/res/drawable-hdpi/ic_gel_widget_icn.png
new file mode 100644
index 0000000..2bfd2c1
--- /dev/null
+++ b/res/drawable-hdpi/ic_gel_widget_icn.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_gel_setting_icn.png b/res/drawable-mdpi/ic_gel_setting_icn.png
new file mode 100644
index 0000000..096e6bc
--- /dev/null
+++ b/res/drawable-mdpi/ic_gel_setting_icn.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_gel_wallpaper_icn.png b/res/drawable-mdpi/ic_gel_wallpaper_icn.png
new file mode 100644
index 0000000..61a7b7e
--- /dev/null
+++ b/res/drawable-mdpi/ic_gel_wallpaper_icn.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_gel_widget_icn.png b/res/drawable-mdpi/ic_gel_widget_icn.png
new file mode 100644
index 0000000..8a2cb7a
--- /dev/null
+++ b/res/drawable-mdpi/ic_gel_widget_icn.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_gel_setting_icn.png b/res/drawable-xhdpi/ic_gel_setting_icn.png
new file mode 100644
index 0000000..fe17163
--- /dev/null
+++ b/res/drawable-xhdpi/ic_gel_setting_icn.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_gel_wallpaper_icn.png b/res/drawable-xhdpi/ic_gel_wallpaper_icn.png
new file mode 100644
index 0000000..d9472d9
--- /dev/null
+++ b/res/drawable-xhdpi/ic_gel_wallpaper_icn.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_gel_widget_icn.png b/res/drawable-xhdpi/ic_gel_widget_icn.png
new file mode 100644
index 0000000..da6e3e9
--- /dev/null
+++ b/res/drawable-xhdpi/ic_gel_widget_icn.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_gel_setting_icn.png b/res/drawable-xxhdpi/ic_gel_setting_icn.png
new file mode 100644
index 0000000..813716d
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_gel_setting_icn.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_gel_wallpaper_icn.png b/res/drawable-xxhdpi/ic_gel_wallpaper_icn.png
new file mode 100644
index 0000000..3525446
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_gel_wallpaper_icn.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_gel_widget_icn.png b/res/drawable-xxhdpi/ic_gel_widget_icn.png
new file mode 100644
index 0000000..9342437
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_gel_widget_icn.png
Binary files differ
diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml
index e05adf2..e4f4c89 100644
--- a/res/layout/overview_panel.xml
+++ b/res/layout/overview_panel.xml
@@ -26,6 +26,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/widget_button_text"
+ android:drawablePadding="4dp"
+ android:drawableTop="@drawable/ic_gel_widget_icn"
android:textSize="18dp"/>
<Space
android:layout_width="@dimen/overview_panel_buttonSpacing"
@@ -35,6 +37,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wallpaper_button_text"
+ android:drawablePadding="4dp"
+ android:drawableTop="@drawable/ic_gel_wallpaper_icn"
android:textSize="18dp" />
<Space
android:layout_width="@dimen/overview_panel_buttonSpacing"
@@ -44,5 +48,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_button_text"
+ android:drawablePadding="4dp"
+ android:drawableTop="@drawable/ic_gel_setting_icn"
android:textSize="18dp" />
</LinearLayout>
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index aad9b9f..9777ea9 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -77,7 +77,6 @@
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
-import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
@@ -132,12 +131,6 @@
static final boolean DEBUG_STRICT_MODE = false;
static final boolean DEBUG_RESUME_TIME = false;
- private static final int MENU_GROUP_WALLPAPER = 1;
- private static final int MENU_WALLPAPER_SETTINGS = Menu.FIRST + 1;
- private static final int MENU_MANAGE_APPS = MENU_WALLPAPER_SETTINGS + 1;
- private static final int MENU_SYSTEM_SETTINGS = MENU_MANAGE_APPS + 1;
- private static final int MENU_HELP = MENU_SYSTEM_SETTINGS + 1;
-
private static final int REQUEST_CREATE_SHORTCUT = 1;
private static final int REQUEST_CREATE_APPWIDGET = 5;
private static final int REQUEST_PICK_APPLICATION = 6;
@@ -482,6 +475,33 @@
return false;
}
+ /**
+ * To be overridden by subclasses to create the custom content and call
+ * {@link #addToCustomContentPage}. This will only be invoked if
+ * {@link #hasCustomContentToLeft()} is {@code true}.
+ */
+ protected void addCustomContentToLeft() {
+ }
+
+ /**
+ * Invoked by subclasses to signal a change to the {@link #addCustomContentToLeft} value to
+ * ensure the custom content page is added or removed if necessary.
+ */
+ protected void invalidateHasCustomContentToLeft() {
+ if (mWorkspace.getScreenOrder().isEmpty()) {
+ // Not bound yet, wait for bindScreens to be called.
+ return;
+ }
+
+ if (!mWorkspace.hasCustomContent() && hasCustomContentToLeft()) {
+ // Create the custom content page and call the subclass to populate it.
+ mWorkspace.createCustomContentPage();
+ addCustomContentToLeft();
+ } else if (mWorkspace.hasCustomContent() && !hasCustomContentToLeft()) {
+ mWorkspace.removeCustomContentPage();
+ }
+ }
+
private void updateGlobalIcons() {
boolean searchVisible = false;
boolean voiceVisible = false;
@@ -896,6 +916,9 @@
}
protected void onFinishBindingItems() {
+ if (hasCustomContentToLeft() && mWorkspace.hasCustomContent()) {
+ addCustomContentToLeft();
+ }
}
QSBScroller mQsbScroller = new QSBScroller() {
@@ -1851,66 +1874,12 @@
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- if (isWorkspaceLocked()) {
- return false;
- }
-
- super.onCreateOptionsMenu(menu);
-
- Intent manageApps = new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
- manageApps.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
- Intent settings = new Intent(android.provider.Settings.ACTION_SETTINGS);
- settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
- String helpUrl = getString(R.string.help_url);
- Intent help = new Intent(Intent.ACTION_VIEW, Uri.parse(helpUrl));
- help.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
-
- menu.add(MENU_GROUP_WALLPAPER, MENU_WALLPAPER_SETTINGS, 0, R.string.menu_wallpaper)
- .setIcon(android.R.drawable.ic_menu_gallery)
- .setAlphabeticShortcut('W');
- menu.add(0, MENU_MANAGE_APPS, 0, R.string.menu_manage_apps)
- .setIcon(android.R.drawable.ic_menu_manage)
- .setIntent(manageApps)
- .setAlphabeticShortcut('M');
- menu.add(0, MENU_SYSTEM_SETTINGS, 0, R.string.menu_settings)
- .setIcon(android.R.drawable.ic_menu_preferences)
- .setIntent(settings)
- .setAlphabeticShortcut('P');
- if (!helpUrl.isEmpty()) {
- menu.add(0, MENU_HELP, 0, R.string.menu_help)
- .setIcon(android.R.drawable.ic_menu_help)
- .setIntent(help)
- .setAlphabeticShortcut('H');
- }
- return true;
- }
-
- @Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
-
- if (mAppsCustomizeTabHost.isTransitioning()) {
- return false;
+ if (!mWorkspace.isInOverviewMode()) {
+ mWorkspace.enterOverviewMode();
}
- boolean allAppsVisible = (mAppsCustomizeTabHost.getVisibility() == View.VISIBLE);
- menu.setGroupVisible(MENU_GROUP_WALLPAPER, !allAppsVisible);
-
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case MENU_WALLPAPER_SETTINGS:
- startWallpaper();
- return true;
- }
-
- return super.onOptionsItemSelected(item);
+ return false;
}
@Override
@@ -3607,7 +3576,8 @@
}
// Create the custom content page (this call updates mDefaultScreen which calls
- // setCurrentPage() so ensure that all pages are added before calling this)
+ // setCurrentPage() so ensure that all pages are added before calling this).
+ // The actual content of the custom page will be added during onFinishBindingItems().
if (!mWorkspace.hasCustomContent() && hasCustomContentToLeft()) {
mWorkspace.createCustomContentPage();
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 76d60a8..c0b2ae3 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -52,7 +52,6 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewParent;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.TextView;
@@ -540,6 +539,24 @@
setCurrentPage(getCurrentPage() + 1);
}
+ public void removeCustomContentPage() {
+ Launcher.addDumpLog(TAG, "10249126 - removeCustomContentPage()", true);
+
+ CellLayout customScreen = getScreenWithId(CUSTOM_CONTENT_SCREEN_ID);
+ if (customScreen == null) {
+ throw new RuntimeException("Expected custom content screen to exist");
+ }
+
+ mWorkspaceScreens.remove(CUSTOM_CONTENT_SCREEN_ID);
+ mScreenOrder.remove(CUSTOM_CONTENT_SCREEN_ID);
+ removeView(customScreen);
+ mCustomContentCallbacks = null;
+
+ // Ensure that the current page and default page are maintained.
+ mDefaultPage = mOriginalDefaultPage - 1;
+ setCurrentPage(getCurrentPage() - 1);
+ }
+
public void addToCustomContentPage(View customContent, CustomContentCallbacks callbacks) {
if (getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID) < 0) {
throw new RuntimeException("Expected custom content screen to exist");
@@ -1326,30 +1343,32 @@
}
private void updateStateForCustomContent(int screenCenter) {
+ float translationX = 0;
+ float progress = 0;
if (hasCustomContent()) {
int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);
int scrollDelta = getScrollForPage(index + 1) - getScrollX();
- float translationX = Math.max(scrollDelta, 0);
- float progress = (1.0f * scrollDelta) /
+ translationX = Math.max(scrollDelta, 0);
+ progress = (1.0f * scrollDelta) /
(getScrollForPage(index + 1) - getScrollForPage(index));
progress = Math.max(0, progress);
+ }
- if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
- mLastCustomContentScrollProgress = progress;
+ if (Float.compare(progress, mLastCustomContentScrollProgress) == 0) return;
+ mLastCustomContentScrollProgress = progress;
- setBackgroundAlpha(progress * 0.8f);
+ setBackgroundAlpha(progress * 0.8f);
- if (mLauncher.getHotseat() != null) {
- mLauncher.getHotseat().setTranslationX(translationX);
- }
+ if (mLauncher.getHotseat() != null) {
+ mLauncher.getHotseat().setTranslationX(translationX);
+ }
- if (getPageIndicator() != null) {
- getPageIndicator().setTranslationX(translationX);
- }
+ if (getPageIndicator() != null) {
+ getPageIndicator().setTranslationX(translationX);
+ }
- if (mCustomContentCallbacks != null) {
- mCustomContentCallbacks.onScrollProgressChanged(progress);
- }
+ if (mCustomContentCallbacks != null) {
+ mCustomContentCallbacks.onScrollProgressChanged(progress);
}
}
@@ -1931,7 +1950,8 @@
AlphaUpdateListener.updateVisibility(getPageIndicator());
}
searchBar.setAlpha(finalSearchBarAlpha);
- AlphaUpdateListener.updateVisibility(mLauncher.getSearchBar());
+ AlphaUpdateListener.updateVisibility(searchBar);
+ updateCustomContentVisibility();
}
if (finalSearchBarAlpha == 0) {
mLauncher.setVoiceButtonProxyVisible(false);
@@ -1998,10 +2018,27 @@
private void onTransitionPrepare() {
mIsSwitchingState = true;
updateChildrenLayersEnabled(false);
- if (mState != Workspace.State.NORMAL) {
- if (hasCustomContent()) {
- mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).setVisibility(INVISIBLE);
- }
+ hideCustomContentIfNecessary();
+ }
+
+ void updateCustomContentVisibility() {
+ int visibility = mState == Workspace.State.NORMAL ? VISIBLE : INVISIBLE;
+ if (hasCustomContent()) {
+ mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).setVisibility(visibility);
+ }
+ }
+
+ void showCustomContentIfNecessary() {
+ boolean show = mState == Workspace.State.NORMAL;
+ if (show && hasCustomContent()) {
+ mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).setVisibility(VISIBLE);
+ }
+ }
+
+ void hideCustomContentIfNecessary() {
+ boolean hide = mState != Workspace.State.NORMAL;
+ if (hide && hasCustomContent()) {
+ mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).setVisibility(INVISIBLE);
}
}
@@ -2018,11 +2055,7 @@
cl.setShortcutAndWidgetAlpha(1f);
}
}
- if (mState == Workspace.State.NORMAL) {
- if (hasCustomContent()) {
- mWorkspaceScreens.get(CUSTOM_CONTENT_SCREEN_ID).setVisibility(VISIBLE);
- }
- }
+ showCustomContentIfNecessary();
}
@Override
@@ -3809,7 +3842,7 @@
@Override
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) {
// We don't dispatch restoreInstanceState to our children using this code path.
- // Some pages will be restored immediately as their items are bound immediately, and
+ // Some pages will be restored immediately as their items are bound immediately, and
// others we will need to wait until after their items are bound.
mSavedStates = container;
}