summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/Launcher.java18
-rw-r--r--src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java12
-rw-r--r--src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java27
-rw-r--r--src/com/android/launcher3/allapps/WorkEduCard.java14
-rw-r--r--src/com/android/launcher3/allapps/WorkModeSwitch.java12
-rw-r--r--src/com/android/launcher3/allapps/WorkPausedCard.java4
-rw-r--r--src/com/android/launcher3/config/FeatureFlags.java2
-rw-r--r--src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java10
-rw-r--r--src/com/android/launcher3/model/BaseLauncherBinder.java8
-rw-r--r--src/com/android/launcher3/model/data/ItemInfoWithIcon.java5
-rw-r--r--src/com/android/launcher3/util/OnboardingPrefs.java9
-rw-r--r--src/com/android/launcher3/util/StartActivityParams.java117
12 files changed, 201 insertions, 37 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 66690431ec..8fb68f1bf6 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1418,8 +1418,7 @@ public class Launcher extends StatefulActivity<LauncherState>
*/
protected void completeAddShortcut(Intent data, int container, int screenId, int cellX,
int cellY, PendingRequestArgs args) {
- if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT
- || args.getPendingIntent().getComponent() == null) {
+ if (args.getRequestCode() != REQUEST_CREATE_SHORTCUT) {
return;
}
@@ -1928,16 +1927,10 @@ public class Launcher extends StatefulActivity<LauncherState>
info.spanX = spanX;
info.spanY = spanY;
- switch (info.itemType) {
- case LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
- case LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET:
- addAppWidgetFromDrop((PendingAddWidgetInfo) info);
- break;
- case LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT:
- processShortcutFromDrop((PendingAddShortcutInfo) info);
- break;
- default:
- throw new IllegalStateException("Unknown item type: " + info.itemType);
+ if (info instanceof PendingAddWidgetInfo) {
+ addAppWidgetFromDrop((PendingAddWidgetInfo) info);
+ } else { // info can only be PendingAddShortcutInfo
+ processShortcutFromDrop((PendingAddShortcutInfo) info);
}
}
@@ -3055,6 +3048,7 @@ public class Launcher extends StatefulActivity<LauncherState>
@Override
public void bindStringCache(StringCache cache) {
mStringCache = cache;
+ mAppsView.updateWorkUI();
}
@Override
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index a7a25f4dce..758bffbeb8 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -7,6 +7,7 @@ import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK
import static com.android.launcher3.LauncherState.NORMAL;
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE;
+import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_NOT_PINNABLE;
import android.appwidget.AppWidgetProviderInfo;
import android.graphics.Point;
@@ -124,12 +125,19 @@ public class LauncherAccessibilityDelegate extends BaseAccessibilityDelegate<Lau
}
}
- if ((item instanceof WorkspaceItemFactory) || (item instanceof WorkspaceItemInfo)
- || (item instanceof PendingAddItemInfo)) {
+ if (supportAddToWorkSpace(item)) {
out.add(mActions.get(ADD_TO_WORKSPACE));
}
}
+ private boolean supportAddToWorkSpace(ItemInfo item) {
+ return (item instanceof WorkspaceItemFactory)
+ || ((item instanceof WorkspaceItemInfo)
+ && (((WorkspaceItemInfo) item).runtimeStatusFlags & FLAG_NOT_PINNABLE) == 0)
+ || ((item instanceof PendingAddItemInfo)
+ && (((PendingAddItemInfo) item).runtimeStatusFlags & FLAG_NOT_PINNABLE) == 0);
+ }
+
/**
* Returns all the accessibility actions that can be handled by the host.
*/
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 1977704588..7e943a907b 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -16,6 +16,8 @@
package com.android.launcher3.allapps;
import static com.android.launcher3.allapps.ActivityAllAppsContainerView.AdapterHolder.SEARCH;
+import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_DISABLED_CARD;
+import static com.android.launcher3.allapps.BaseAllAppsAdapter.VIEW_TYPE_WORK_EDU_CARD;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_COUNT;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_PERSONAL_TAB;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ALLAPPS_TAP_ON_WORK_TAB;
@@ -76,6 +78,7 @@ import com.android.launcher3.keyboard.FocusedItemDecorator;
import com.android.launcher3.model.StringCache;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.testing.shared.TestProtocol;
+import com.android.launcher3.util.Executors;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
@@ -1108,6 +1111,30 @@ public class ActivityAllAppsContainerView<T extends Context & ActivityContext>
return view.getGlobalVisibleRect(new Rect());
}
+ /** Called in Launcher#bindStringCache() to update the UI when cache is updated. */
+ public void updateWorkUI() {
+ setDeviceManagementResources();
+ if (mWorkManager.getWorkModeSwitch() != null) {
+ mWorkManager.getWorkModeSwitch().updateStringFromCache();
+ }
+ inflateWorkCardsIfNeeded();
+ }
+
+ private void inflateWorkCardsIfNeeded() {
+ AllAppsRecyclerView workRV = mAH.get(AdapterHolder.WORK).mRecyclerView;
+ if (workRV != null) {
+ for (int i = 0; i < workRV.getChildCount(); i++) {
+ View currentView = workRV.getChildAt(i);
+ int currentItemViewType = workRV.getChildViewHolder(currentView).getItemViewType();
+ if (currentItemViewType == VIEW_TYPE_WORK_EDU_CARD) {
+ ((WorkEduCard) currentView).updateStringFromCache();
+ } else if (currentItemViewType == VIEW_TYPE_WORK_DISABLED_CARD) {
+ ((WorkPausedCard) currentView).updateStringFromCache();
+ }
+ }
+ }
+ }
+
@VisibleForTesting
public boolean isPersonalTabVisible() {
return isDescendantViewVisible(R.id.tab_personal);
diff --git a/src/com/android/launcher3/allapps/WorkEduCard.java b/src/com/android/launcher3/allapps/WorkEduCard.java
index b4cdc967dc..1059097c5a 100644
--- a/src/com/android/launcher3/allapps/WorkEduCard.java
+++ b/src/com/android/launcher3/allapps/WorkEduCard.java
@@ -76,11 +76,7 @@ public class WorkEduCard extends FrameLayout implements
super.onFinishInflate();
findViewById(R.id.action_btn).setOnClickListener(this);
- StringCache cache = mActivityContext.getStringCache();
- if (cache != null) {
- TextView title = findViewById(R.id.work_apps_paused_title);
- title.setText(cache.workProfileEdu);
- }
+ updateStringFromCache();
}
@Override
@@ -121,4 +117,12 @@ public class WorkEduCard extends FrameLayout implements
public void setPosition(int position) {
mPosition = position;
}
+
+ public void updateStringFromCache() {
+ StringCache cache = mActivityContext.getStringCache();
+ if (cache != null) {
+ TextView title = findViewById(R.id.work_apps_paused_title);
+ title.setText(cache.workProfileEdu);
+ }
+ }
}
diff --git a/src/com/android/launcher3/allapps/WorkModeSwitch.java b/src/com/android/launcher3/allapps/WorkModeSwitch.java
index 8c2fb195c6..f84876b52c 100644
--- a/src/com/android/launcher3/allapps/WorkModeSwitch.java
+++ b/src/com/android/launcher3/allapps/WorkModeSwitch.java
@@ -92,10 +92,7 @@ public class WorkModeSwitch extends LinearLayout implements Insettable,
}
setInsets(mActivityContext.getDeviceProfile().getInsets());
- StringCache cache = mActivityContext.getStringCache();
- if (cache != null) {
- mTextView.setText(cache.workProfilePauseButton);
- }
+ updateStringFromCache();
getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
}
@@ -213,4 +210,11 @@ public class WorkModeSwitch extends LinearLayout implements Insettable,
public int getScrollThreshold() {
return mScrollThreshold;
}
+
+ public void updateStringFromCache(){
+ StringCache cache = mActivityContext.getStringCache();
+ if (cache != null) {
+ mTextView.setText(cache.workProfilePauseButton);
+ }
+ }
}
diff --git a/src/com/android/launcher3/allapps/WorkPausedCard.java b/src/com/android/launcher3/allapps/WorkPausedCard.java
index 26a78039cb..18826673a1 100644
--- a/src/com/android/launcher3/allapps/WorkPausedCard.java
+++ b/src/com/android/launcher3/allapps/WorkPausedCard.java
@@ -57,6 +57,10 @@ public class WorkPausedCard extends LinearLayout implements View.OnClickListener
mBtn = findViewById(R.id.enable_work_apps);
mBtn.setOnClickListener(this);
+ updateStringFromCache();
+ }
+
+ public void updateStringFromCache() {
StringCache cache = mActivityContext.getStringCache();
if (cache != null) {
setWorkProfilePausedResources(cache);
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index f5f6769c33..0f60f7f7a2 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -277,7 +277,7 @@ public final class FeatureFlags {
+ " is enabled or in prefix state");
public static final BooleanFlag ENABLE_SEARCH_UNINSTALLED_APPS = getReleaseFlag(270395269,
- "ENABLE_SEARCH_UNINSTALLED_APPS", DISABLED, "Search uninstalled app results.");
+ "ENABLE_SEARCH_UNINSTALLED_APPS", ENABLED, "Search uninstalled app results.");
// TODO(Block 20): Clean up flags
public static final BooleanFlag ENABLE_SCRIM_FOR_APP_LAUNCH = getDebugFlag(270393276,
diff --git a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
index 7bdec1cfde..0f3cad66a2 100644
--- a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
+++ b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java
@@ -16,6 +16,8 @@
package com.android.launcher3.dragndrop;
+import static android.content.pm.LauncherApps.EXTRA_PIN_ITEM_REQUEST;
+
import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY;
import static com.android.launcher3.LauncherState.EDIT_MODE;
import static com.android.launcher3.LauncherState.SPRING_LOADED;
@@ -25,6 +27,7 @@ import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.LauncherApps;
import android.content.pm.LauncherApps.PinItemRequest;
import android.content.pm.PackageManager;
@@ -41,6 +44,7 @@ import com.android.launcher3.icons.IconCache;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.pm.PinRequestHelper;
import com.android.launcher3.pm.ShortcutConfigActivityInfo;
+import com.android.launcher3.util.StartActivityParams;
import java.util.function.Supplier;
@@ -105,7 +109,11 @@ public class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo {
@Override
public boolean startConfigActivity(Activity activity, int requestCode) {
- return false;
+ new StartActivityParams(activity, requestCode).deliverResult(
+ activity,
+ Activity.RESULT_OK,
+ new Intent().putExtra(EXTRA_PIN_ITEM_REQUEST, mRequestSupplier.get()));
+ return true;
}
@Override
diff --git a/src/com/android/launcher3/model/BaseLauncherBinder.java b/src/com/android/launcher3/model/BaseLauncherBinder.java
index 5d85b1cf6e..5997637c9d 100644
--- a/src/com/android/launcher3/model/BaseLauncherBinder.java
+++ b/src/com/android/launcher3/model/BaseLauncherBinder.java
@@ -312,7 +312,8 @@ public abstract class BaseLauncherBinder {
currentScreenIds, pendingTasks, workspaceItemCount, isBindSync);
}, mUiExecutor);
- mCallbacks.bindStringCache(mBgDataModel.stringCache.clone());
+ StringCache cacheClone = mBgDataModel.stringCache.clone();
+ executeCallbacksTask(c -> c.bindStringCache(cacheClone), pendingExecutor);
}
private void bindWorkspaceItems(
@@ -440,9 +441,8 @@ public abstract class BaseLauncherBinder {
.resumeModelPush(FLAG_LOADER_RUNNING);
});
- for (Callbacks cb : mCallbacksList) {
- cb.bindStringCache(mBgDataModel.stringCache.clone());
- }
+ StringCache cacheClone = mBgDataModel.stringCache.clone();
+ executeCallbacksTask(c -> c.bindStringCache(cacheClone), mUiExecutor);
}
private void bindWorkspaceItems(final ArrayList<ItemInfo> workspaceItems) {
diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
index e5fb015f2e..b4a935a74a 100644
--- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
+++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
@@ -119,6 +119,11 @@ public abstract class ItemInfoWithIcon extends ItemInfo {
| FLAG_DISABLED_VERSION_LOWER;
/**
+ * Flag indicating this item can't be pinned to home screen.
+ */
+ public static final int FLAG_NOT_PINNABLE = 1 << 13;
+
+ /**
* Status associated with the system state of the underlying item. This is calculated every
* time a new info is created and not persisted on the disk.
*/
diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java
index 65736916d8..348c8d8a4c 100644
--- a/src/com/android/launcher3/util/OnboardingPrefs.java
+++ b/src/com/android/launcher3/util/OnboardingPrefs.java
@@ -40,17 +40,14 @@ public class OnboardingPrefs<T extends ActivityContext> {
public static final String HOTSEAT_LONGPRESS_TIP_SEEN = "launcher.hotseat_longpress_tip_seen";
public static final String SEARCH_KEYBOARD_EDU_SEEN = "launcher.search_edu_seen";
public static final String SEARCH_SNACKBAR_COUNT = "launcher.keyboard_snackbar_count";
- public static final String SEARCH_ONBOARDING_COUNT = "launcher.search_onboarding_count";
public static final String ALL_APPS_VISITED_COUNT = "launcher.all_apps_visited_count";
- public static final String QSB_SEARCH_ONBOARDING_CARD_DISMISSED = "launcher.qsb_edu_dismiss";
public static final String TASKBAR_EDU_TOOLTIP_STEP = "launcher.taskbar_edu_tooltip_step";
// When adding a new key, add it here as well, to be able to reset it from Developer Options.
public static final Map<String, String[]> ALL_PREF_KEYS = Map.of(
"All Apps Bounce", new String[] { HOME_BOUNCE_SEEN, HOME_BOUNCE_COUNT },
"Hybrid Hotseat Education", new String[] { HOTSEAT_DISCOVERY_TIP_COUNT,
HOTSEAT_LONGPRESS_TIP_SEEN },
- "Search Education", new String[] { SEARCH_KEYBOARD_EDU_SEEN, SEARCH_SNACKBAR_COUNT,
- SEARCH_ONBOARDING_COUNT, QSB_SEARCH_ONBOARDING_CARD_DISMISSED},
+ "Search Education", new String[] { SEARCH_KEYBOARD_EDU_SEEN, SEARCH_SNACKBAR_COUNT},
"Taskbar Education", new String[] { TASKBAR_EDU_TOOLTIP_STEP },
"All Apps Visited Count", new String[] {ALL_APPS_VISITED_COUNT}
);
@@ -62,7 +59,6 @@ public class OnboardingPrefs<T extends ActivityContext> {
HOME_BOUNCE_SEEN,
HOTSEAT_LONGPRESS_TIP_SEEN,
SEARCH_KEYBOARD_EDU_SEEN,
- QSB_SEARCH_ONBOARDING_CARD_DISMISSED
})
@Retention(RetentionPolicy.SOURCE)
public @interface EventBoolKey {}
@@ -74,7 +70,6 @@ public class OnboardingPrefs<T extends ActivityContext> {
HOME_BOUNCE_COUNT,
HOTSEAT_DISCOVERY_TIP_COUNT,
SEARCH_SNACKBAR_COUNT,
- SEARCH_ONBOARDING_COUNT,
ALL_APPS_VISITED_COUNT,
TASKBAR_EDU_TOOLTIP_STEP,
})
@@ -88,8 +83,6 @@ public class OnboardingPrefs<T extends ActivityContext> {
maxCounts.put(HOME_BOUNCE_COUNT, 3);
maxCounts.put(HOTSEAT_DISCOVERY_TIP_COUNT, 5);
maxCounts.put(SEARCH_SNACKBAR_COUNT, 3);
- // This is the sum of all onboarding cards. Currently there is only 1 card shown 3 times.
- maxCounts.put(SEARCH_ONBOARDING_COUNT, 3);
maxCounts.put(ALL_APPS_VISITED_COUNT, 20);
maxCounts.put(TASKBAR_EDU_TOOLTIP_STEP, 2);
MAX_COUNTS = Collections.unmodifiableMap(maxCounts);
diff --git a/src/com/android/launcher3/util/StartActivityParams.java b/src/com/android/launcher3/util/StartActivityParams.java
new file mode 100644
index 0000000000..6e60b2a0d1
--- /dev/null
+++ b/src/com/android/launcher3/util/StartActivityParams.java
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2019 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.util;
+
+import static android.app.PendingIntent.FLAG_MUTABLE;
+import static android.app.PendingIntent.FLAG_ONE_SHOT;
+import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.app.PendingIntent.CanceledException;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentSender;
+import android.os.Bundle;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.Log;
+
+/**
+ * Wrapper class for parameters to start an activity.
+ */
+public class StartActivityParams implements Parcelable {
+
+ private static final String TAG = "StartActivityParams";
+
+ private final PendingIntent mPICallback;
+ public final int requestCode;
+
+ public Intent intent;
+
+ public IntentSender intentSender;
+ public Intent fillInIntent;
+ public int flagsMask;
+ public int flagsValues;
+ public int extraFlags;
+ public Bundle options;
+
+ public StartActivityParams(Activity activity, int requestCode) {
+ this(activity.createPendingResult(requestCode, new Intent(),
+ FLAG_ONE_SHOT | FLAG_UPDATE_CURRENT | FLAG_MUTABLE), requestCode);
+ }
+
+ public StartActivityParams(PendingIntent pendingIntent, int requestCode) {
+ this.mPICallback = pendingIntent;
+ this.requestCode = requestCode;
+ }
+
+ private StartActivityParams(Parcel parcel) {
+ mPICallback = parcel.readTypedObject(PendingIntent.CREATOR);
+ requestCode = parcel.readInt();
+ intent = parcel.readTypedObject(Intent.CREATOR);
+
+ intentSender = parcel.readTypedObject(IntentSender.CREATOR);
+ fillInIntent = parcel.readTypedObject(Intent.CREATOR);
+ flagsMask = parcel.readInt();
+ flagsValues = parcel.readInt();
+ extraFlags = parcel.readInt();
+ options = parcel.readBundle();
+ }
+
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel parcel, int flags) {
+ parcel.writeTypedObject(mPICallback, flags);
+ parcel.writeInt(requestCode);
+ parcel.writeTypedObject(intent, flags);
+
+ parcel.writeTypedObject(intentSender, flags);
+ parcel.writeTypedObject(fillInIntent, flags);
+ parcel.writeInt(flagsMask);
+ parcel.writeInt(flagsValues);
+ parcel.writeInt(extraFlags);
+ parcel.writeBundle(options);
+ }
+
+ /** Perform the operation on the pendingIntent. */
+ public void deliverResult(Context context, int resultCode, Intent data) {
+ try {
+ if (mPICallback != null) {
+ mPICallback.send(context, resultCode, data);
+ }
+ } catch (CanceledException e) {
+ Log.e(TAG, "Unable to send back result", e);
+ }
+ }
+
+ public static final Parcelable.Creator<StartActivityParams> CREATOR =
+ new Parcelable.Creator<>() {
+ public StartActivityParams createFromParcel(Parcel source) {
+ return new StartActivityParams(source);
+ }
+
+ public StartActivityParams[] newArray(int size) {
+ return new StartActivityParams[size];
+ }
+ };
+}