Merge "Removed disableAllApps flag" into ub-launcher3-burnaby

This commit is contained in:
Sunny Goyal
2015-03-02 19:33:35 +00:00
committed by Android (Google) Code Review
10 changed files with 60 additions and 186 deletions
@@ -358,7 +358,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
super.onLayout(changed, l, t, r, b);
if (!isDataReady()) {
if ((LauncherAppState.isDisableAllApps() || !mApps.isEmpty()) && !mWidgets.isEmpty()) {
if ((!mApps.isEmpty()) && !mWidgets.isEmpty()) {
post(new Runnable() {
// This code triggers requestLayout so must be posted outside of the
// layout pass.
@@ -1402,11 +1402,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
public void setApps(ArrayList<AppInfo> list) {
if (!LauncherAppState.isDisableAllApps()) {
mApps = list;
Collections.sort(mApps, LauncherModel.getAppNameComparator());
updatePageCountsAndInvalidateData();
}
mApps = list;
Collections.sort(mApps, LauncherModel.getAppNameComparator());
updatePageCountsAndInvalidateData();
}
public ArrayList<AppInfo> getApps() {
@@ -1425,10 +1423,8 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
public void addApps(ArrayList<AppInfo> list) {
if (!LauncherAppState.isDisableAllApps()) {
addAppsWithoutInvalidate(list);
updatePageCountsAndInvalidateData();
}
addAppsWithoutInvalidate(list);
updatePageCountsAndInvalidateData();
}
private int findAppByComponent(List<AppInfo> list, AppInfo item) {
ComponentName removeComponent = item.intent.getComponent();
@@ -1454,20 +1450,16 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
}
}
public void removeApps(ArrayList<AppInfo> appInfos) {
if (!LauncherAppState.isDisableAllApps()) {
removeAppsWithoutInvalidate(appInfos);
updatePageCountsAndInvalidateData();
}
removeAppsWithoutInvalidate(appInfos);
updatePageCountsAndInvalidateData();
}
public void updateApps(ArrayList<AppInfo> list) {
// We remove and re-add the updated applications list because it's properties may have
// changed (ie. the title), and this will ensure that the items will be in their proper
// place in the list.
if (!LauncherAppState.isDisableAllApps()) {
removeAppsWithoutInvalidate(list);
addAppsWithoutInvalidate(list);
updatePageCountsAndInvalidateData();
}
removeAppsWithoutInvalidate(list);
addAppsWithoutInvalidate(list);
updatePageCountsAndInvalidateData();
}
public void reset() {
@@ -144,13 +144,11 @@ public class DeleteDropTarget extends ButtonDropTarget {
return true;
}
if (!LauncherAppState.isDisableAllApps() &&
item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
return true;
}
if (!LauncherAppState.isDisableAllApps() &&
item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&
item instanceof AppInfo) {
AppInfo appInfo = (AppInfo) info;
return (appInfo.flags & AppInfo.DOWNLOADED_FLAG) != 0;
@@ -158,12 +156,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION &&
item instanceof ShortcutInfo) {
if (LauncherAppState.isDisableAllApps()) {
ShortcutInfo shortcutInfo = (ShortcutInfo) info;
return (shortcutInfo.flags & AppInfo.DOWNLOADED_FLAG) != 0;
} else {
return true;
}
return true;
}
}
return false;
@@ -173,8 +166,7 @@ public class DeleteDropTarget extends ButtonDropTarget {
@Override
public void onDragStart(DragSource source, Object info, int dragAction) {
boolean isVisible = true;
boolean useUninstallLabel = !LauncherAppState.isDisableAllApps() &&
isAllAppsApplication(source, info);
boolean useUninstallLabel = isAllAppsApplication(source, info);
boolean useDeleteLabel = !useUninstallLabel && source.supportsDeleteDropTarget();
// If we are dragging an application from AppsCustomize, only show the control if we can
@@ -277,12 +269,6 @@ public class DeleteDropTarget extends ButtonDropTarget {
}
private boolean isUninstallFromWorkspace(DragObject d) {
if (LauncherAppState.isDisableAllApps() && isDragSourceWorkspaceOrFolder(d)
&& (d.dragInfo instanceof ShortcutInfo)) {
ShortcutInfo shortcut = (ShortcutInfo) d.dragInfo;
// Only allow manifest shortcuts to initiate an un-install.
return !InstallShortcutReceiver.isValidShortcutLaunchIntent(shortcut.intent);
}
return false;
}
+1 -1
View File
@@ -137,7 +137,7 @@ public class DeviceProfile {
DeviceProfile(String n, float w, float h, float r, float c,
float is, float its, float hs, float his, int dlId) {
// Ensure that we have an odd number of hotseat items (since we need to place all apps)
if (!LauncherAppState.isDisableAllApps() && hs % 2 == 0) {
if (hs % 2 == 0) {
throw new RuntimeException("All Device Profiles must have an odd number of hotseat spaces");
}
+7 -8
View File
@@ -56,23 +56,22 @@ public class DynamicGrid {
DisplayMetrics dm = resources.getDisplayMetrics();
ArrayList<DeviceProfile> deviceProfiles =
new ArrayList<DeviceProfile>();
boolean hasAA = !LauncherAppState.isDisableAllApps();
DEFAULT_ICON_SIZE_PX = pxFromDp(DEFAULT_ICON_SIZE_DP, dm);
// Our phone profiles include the bar sizes in each orientation
deviceProfiles.add(new DeviceProfile("Super Short Stubby",
255, 300, 2, 3, 48, 13, (hasAA ? 3 : 5), 48, R.xml.default_workspace_4x4));
255, 300, 2, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Shorter Stubby",
255, 400, 3, 3, 48, 13, (hasAA ? 3 : 5), 48, R.xml.default_workspace_4x4));
255, 400, 3, 3, 48, 13, 3, 48, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Short Stubby",
275, 420, 3, 4, 48, 13, (hasAA ? 5 : 5), 48, R.xml.default_workspace_4x4));
275, 420, 3, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Stubby",
255, 450, 3, 4, 48, 13, (hasAA ? 5 : 5), 48, R.xml.default_workspace_4x4));
255, 450, 3, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Nexus S",
296, 491.33f, 4, 4, 48, 13, (hasAA ? 5 : 5), 48, R.xml.default_workspace_4x4));
296, 491.33f, 4, 4, 48, 13, 5, 48, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Nexus 4",
335, 567, 4, 4, DEFAULT_ICON_SIZE_DP, 13, (hasAA ? 5 : 5), 56, R.xml.default_workspace_4x4));
335, 567, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Nexus 5",
359, 567, 4, 4, DEFAULT_ICON_SIZE_DP, 13, (hasAA ? 5 : 5), 56, R.xml.default_workspace_4x4));
359, 567, 4, 4, DEFAULT_ICON_SIZE_DP, 13, 5, 56, R.xml.default_workspace_4x4));
deviceProfiles.add(new DeviceProfile("Large Phone",
406, 694, 5, 5, 64, 14.4f, 5, 56, R.xml.default_workspace_5x5));
// The tablet profile is odd in that the landscape orientation
+3 -14
View File
@@ -143,13 +143,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
Resources res = getResources();
mMaxCountX = (int) grid.numColumns;
// Allow scrolling folders when DISABLE_ALL_APPS is true.
if (LauncherAppState.isDisableAllApps()) {
mMaxCountY = mMaxNumItems = Integer.MAX_VALUE;
} else {
mMaxCountY = (int) grid.numRows;
mMaxNumItems = mMaxCountX * mMaxCountY;
}
mMaxCountY = (int) grid.numRows;
mMaxNumItems = mMaxCountX * mMaxCountY;
mInputMethodManager = (InputMethodManager)
getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -1012,13 +1007,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
int contentAreaHeightSpec = MeasureSpec.makeMeasureSpec(getContentAreaHeight(),
MeasureSpec.EXACTLY);
if (LauncherAppState.isDisableAllApps()) {
// Don't cap the height of the content to allow scrolling.
mContent.setFixedSize(getContentAreaWidth(), mContent.getDesiredHeight());
} else {
mContent.setFixedSize(getContentAreaWidth(), getContentAreaHeight());
}
mContent.setFixedSize(getContentAreaWidth(), getContentAreaHeight());
mScrollView.measure(contentAreaWidthSpec, contentAreaHeightSpec);
mFolderName.measure(contentAreaWidthSpec,
MeasureSpec.makeMeasureSpec(mFolderNameHeight, MeasureSpec.EXACTLY));
+25 -57
View File
@@ -24,12 +24,9 @@ import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import java.util.ArrayList;
public class Hotseat extends FrameLayout {
private CellLayout mContent;
@@ -94,19 +91,11 @@ public class Hotseat extends FrameLayout {
}
public int getAllAppsButtonRank() {
if (LauncherAppState.isDisableAllApps()) {
return -1;
} else {
return mAllAppsButtonRank;
}
return mAllAppsButtonRank;
}
public boolean isAllAppsButtonRank(int rank) {
if (LauncherAppState.isDisableAllApps()) {
return false;
} else {
return rank == mAllAppsButtonRank;
}
return rank == mAllAppsButtonRank;
}
/** This returns the coordinates of an app in a given cell, relative to the DragLayer */
@@ -149,35 +138,33 @@ public class Hotseat extends FrameLayout {
void resetLayout() {
mContent.removeAllViewsInLayout();
if (!LauncherAppState.isDisableAllApps()) {
// Add the Apps button
Context context = getContext();
// Add the Apps button
Context context = getContext();
LayoutInflater inflater = LayoutInflater.from(context);
TextView allAppsButton = (TextView)
inflater.inflate(R.layout.all_apps_button, mContent, false);
Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
LayoutInflater inflater = LayoutInflater.from(context);
TextView allAppsButton = (TextView)
inflater.inflate(R.layout.all_apps_button, mContent, false);
Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);
Utilities.resizeIconDrawable(d);
allAppsButton.setCompoundDrawables(null, d, null, null);
Utilities.resizeIconDrawable(d);
allAppsButton.setCompoundDrawables(null, d, null, null);
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
if (mLauncher != null) {
allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
mLauncher.setAllAppsButton(allAppsButton);
allAppsButton.setOnClickListener(mLauncher);
allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
}
// Note: We do this to ensure that the hotseat is always laid out in the orientation of
// the hotseat in order regardless of which orientation they were added
int x = getCellXFromOrder(mAllAppsButtonRank);
int y = getCellYFromOrder(mAllAppsButtonRank);
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1);
lp.canReorder = false;
mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
if (mLauncher != null) {
allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
mLauncher.setAllAppsButton(allAppsButton);
allAppsButton.setOnClickListener(mLauncher);
allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
}
// Note: We do this to ensure that the hotseat is always laid out in the orientation of
// the hotseat in order regardless of which orientation they were added
int x = getCellXFromOrder(mAllAppsButtonRank);
int y = getCellYFromOrder(mAllAppsButtonRank);
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x,y,1,1);
lp.canReorder = false;
mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
}
@Override
@@ -189,23 +176,4 @@ public class Hotseat extends FrameLayout {
}
return false;
}
void addAppsToAllAppsFolder(ArrayList<AppInfo> apps) {
if (LauncherAppState.isDisableAllApps()) {
View v = mContent.getChildAt(getCellXFromOrder(mAllAppsButtonRank), getCellYFromOrder(mAllAppsButtonRank));
FolderIcon fi = null;
if (v instanceof FolderIcon) {
fi = (FolderIcon) v;
} else {
return;
}
FolderInfo info = fi.getFolderInfo();
for (AppInfo a: apps) {
ShortcutInfo si = a.makeShortcut();
info.add(si);
}
}
}
}
@@ -186,11 +186,6 @@ public class InstallShortcutReceiver extends BroadcastReceiver {
final PendingInstallShortcutInfo pendingInfo = iter.next();
final Intent intent = pendingInfo.launchIntent;
if (LauncherAppState.isDisableAllApps() && !isValidShortcutLaunchIntent(intent)) {
if (DBG) Log.d(TAG, "Ignoring shortcut with launchIntent:" + intent);
continue;
}
// If the intent specifies a package, make sure the package exists
String packageName = pendingInfo.getTargetPackage();
if (!TextUtils.isEmpty(packageName)) {
+8 -20
View File
@@ -167,7 +167,6 @@ public class Launcher extends Activity
// To turn on these properties, type
// adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS]
static final String DUMP_STATE_PROPERTY = "launcher_dump_state";
static final String DISABLE_ALL_APPS_PROPERTY = "launcher_noallapps";
// The Intent extra that defines whether to ignore the launch animation
static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
@@ -3344,8 +3343,7 @@ public class Launcher extends Activity
Workspace.State.OVERVIEW_HIDDEN : Workspace.State.NORMAL_HIDDEN;
Animator workspaceAnim =
mWorkspace.getChangeStateAnimation(workspaceState, animated, layerViews);
if (!LauncherAppState.isDisableAllApps()
|| contentType == AppsCustomizePagedView.ContentType.Widgets) {
if (contentType == AppsCustomizePagedView.ContentType.Widgets) {
// Set the content type for the all apps/widgets space
mAppsCustomizeTabHost.setContentTypeImmediate(contentType);
}
@@ -4238,8 +4236,7 @@ public class Launcher extends Activity
// Remove the extra empty screen
mWorkspace.removeExtraEmptyScreen(false, false);
if (!LauncherAppState.isDisableAllApps() &&
addedApps != null && mAppsCustomizeContent != null) {
if (addedApps != null && mAppsCustomizeContent != null) {
mAppsCustomizeContent.addApps(addedApps);
}
}
@@ -4614,17 +4611,10 @@ public class Launcher extends Activity
* Implementation of the method from LauncherModel.Callbacks.
*/
public void bindAllApplications(final ArrayList<AppInfo> apps) {
if (LauncherAppState.isDisableAllApps()) {
if (mAppsCustomizeContent != null) {
mAppsCustomizeContent.onPackagesUpdated(
LauncherModel.getSortedWidgetsAndShortcuts(this));
}
} else {
if (mAppsCustomizeContent != null) {
mAppsCustomizeContent.setApps(apps);
mAppsCustomizeContent.onPackagesUpdated(
LauncherModel.getSortedWidgetsAndShortcuts(this));
}
if (mAppsCustomizeContent != null) {
mAppsCustomizeContent.setApps(apps);
mAppsCustomizeContent.onPackagesUpdated(
LauncherModel.getSortedWidgetsAndShortcuts(this));
}
if (mLauncherCallbacks != null) {
mLauncherCallbacks.bindAllApplications(apps);
@@ -4646,8 +4636,7 @@ public class Launcher extends Activity
return;
}
if (!LauncherAppState.isDisableAllApps() &&
mAppsCustomizeContent != null) {
if (mAppsCustomizeContent != null) {
mAppsCustomizeContent.updateApps(apps);
}
}
@@ -4762,8 +4751,7 @@ public class Launcher extends Activity
}
// Update AllApps
if (!LauncherAppState.isDisableAllApps() &&
mAppsCustomizeContent != null) {
if (mAppsCustomizeContent != null) {
mAppsCustomizeContent.removeApps(appInfos);
}
}
@@ -43,9 +43,6 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks {
private static final String TAG = "LauncherAppState";
private static final boolean DEBUG = false;
private final AppFilter mAppFilter;
private final BuildInfo mBuildInfo;
@@ -283,12 +280,6 @@ public class LauncherAppState implements DeviceProfile.DeviceProfileCallbacks {
Utilities.setIconSize(grid.iconSizePx);
}
public static boolean isDisableAllApps() {
// Returns false on non-dogfood builds.
return getInstance().mBuildInfo.isDogfoodBuild() &&
Utilities.isPropertyEnabled(Launcher.DISABLE_ALL_APPS_PROPERTY);
}
public static boolean isDogfoodBuild() {
return getInstance().mBuildInfo.isDogfoodBuild();
}
+1 -35
View File
@@ -1625,12 +1625,6 @@ public class LauncherModel extends BroadcastReceiver
}
}
if (LauncherAppState.isDisableAllApps()) {
// Ensure that all the applications that are in the system are
// represented on the home screen.
verifyApplications();
}
// Clear out this reference, otherwise we end up holding it until all of the
// callback runnables are done.
mContext = null;
@@ -1681,28 +1675,6 @@ public class LauncherModel extends BroadcastReceiver
}
}
private void verifyApplications() {
final Context context = mApp.getContext();
// Cross reference all the applications in our apps list with items in the workspace
ArrayList<ItemInfo> tmpInfos;
ArrayList<ItemInfo> added = new ArrayList<ItemInfo>();
synchronized (sBgLock) {
for (AppInfo app : mBgAllAppsList.data) {
tmpInfos = getItemInfoForComponentName(app.componentName, app.user);
if (tmpInfos.isEmpty()) {
// We are missing an application icon, so add this to the workspace
added.add(app);
// This is a rare event, so lets log it
Log.e(TAG, "Missing Application on load: " + app);
}
}
}
if (!added.isEmpty()) {
addAndBindAddedWorkspaceApps(context, added);
}
}
// check & update map of what's occupied; used to discard overlapping/invalid items
private boolean checkItemPlacement(HashMap<Long, ItemInfo[][]> occupied, ItemInfo item) {
LauncherAppState app = LauncherAppState.getInstance();
@@ -3085,13 +3057,7 @@ public class LauncherModel extends BroadcastReceiver
new HashMap<ComponentName, AppInfo>();
if (added != null) {
// Ensure that we add all the workspace applications to the db
if (LauncherAppState.isDisableAllApps()) {
final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
addAndBindAddedWorkspaceApps(context, addedInfos);
} else {
addAppsToAllApps(context, added);
}
addAppsToAllApps(context, added);
for (AppInfo ai : added) {
addedOrUpdatedApps.put(ai.componentName, ai);
}