summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java100
-rw-r--r--src/com/android/launcher3/PageIndicatorMarker.java18
-rw-r--r--src/com/android/launcher3/Workspace.java51
3 files changed, 85 insertions, 84 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index aad9b9f35..9777ea94a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -77,7 +77,6 @@ import android.view.HapticFeedbackConstants;
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 @@ public class Launcher extends Activity
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 @@ public class Launcher extends Activity
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 @@ public class Launcher extends Activity
}
protected void onFinishBindingItems() {
+ if (hasCustomContentToLeft() && mWorkspace.hasCustomContent()) {
+ addCustomContentToLeft();
+ }
}
QSBScroller mQsbScroller = new QSBScroller() {
@@ -1851,66 +1874,12 @@ public class Launcher extends Activity
}
@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 @@ public class Launcher extends Activity
}
// 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/PageIndicatorMarker.java b/src/com/android/launcher3/PageIndicatorMarker.java
index f64c14fdc..1ad0abb6b 100644
--- a/src/com/android/launcher3/PageIndicatorMarker.java
+++ b/src/com/android/launcher3/PageIndicatorMarker.java
@@ -57,26 +57,38 @@ public class PageIndicatorMarker extends FrameLayout {
if (immediate) {
mActiveMarker.animate().cancel();
mActiveMarker.setAlpha(1f);
+ mActiveMarker.setScaleX(1f);
+ mActiveMarker.setScaleY(1f);
mInactiveMarker.animate().cancel();
mInactiveMarker.setAlpha(0f);
} else {
- mActiveMarker.animate().alpha(1f)
+ mActiveMarker.animate()
+ .alpha(1f)
+ .scaleX(1f)
+ .scaleY(1f)
.setDuration(MARKER_FADE_DURATION).start();
- mInactiveMarker.animate().alpha(0f)
+ mInactiveMarker.animate()
+ .alpha(0f)
.setDuration(MARKER_FADE_DURATION).start();
}
mIsActive = true;
}
+
void inactivate(boolean immediate) {
if (immediate) {
mInactiveMarker.animate().cancel();
mInactiveMarker.setAlpha(1f);
mActiveMarker.animate().cancel();
mActiveMarker.setAlpha(0f);
+ mActiveMarker.setScaleX(0.5f);
+ mActiveMarker.setScaleY(0.5f);
} else {
mInactiveMarker.animate().alpha(1f)
.setDuration(MARKER_FADE_DURATION).start();
- mActiveMarker.animate().alpha(0f)
+ mActiveMarker.animate()
+ .alpha(0f)
+ .scaleX(0.5f)
+ .scaleY(0.5f)
.setDuration(MARKER_FADE_DURATION).start();
}
mIsActive = false;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 6cb6a5744..c0b2ae390 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -52,7 +52,6 @@ import android.view.Display;
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 @@ public class Workspace extends SmoothPagedView
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 @@ public class Workspace extends SmoothPagedView
}
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);
}
}
@@ -3823,7 +3842,7 @@ public class Workspace extends SmoothPagedView
@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;
}