Merge "Revert "Adding some logging around launcher grid when device profile changes"" into ub-launcher3-dorval
diff --git a/res/drawable/ic_instant_app.xml b/res/drawable/ic_instant_app.xml
deleted file mode 100644
index be5a3e0..0000000
--- a/res/drawable/ic_instant_app.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2017 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.
--->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="@dimen/badge_size"
- android:height="@dimen/badge_size"
- android:viewportWidth="18"
- android:viewportHeight="18">
-
- <path
- android:fillColor="@android:color/black"
- android:fillType="evenOdd"
- android:strokeWidth="1"
- android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
- <path
- android:fillColor="@android:color/white"
- android:fillType="evenOdd"
- android:strokeWidth="1"
- android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
- <path
- android:fillColor="@android:color/white"
- android:fillType="evenOdd"
- android:strokeWidth="1"
- android:pathData="M 9 0 C 13.9705627485 0 18 4.02943725152 18 9 C 18 13.9705627485 13.9705627485 18 9 18 C 4.02943725152 18 0 13.9705627485 0 9 C 0 4.02943725152 4.02943725152 0 9 0 Z" />
- <path
- android:fillColor="@android:color/black"
- android:fillAlpha="0.87"
- android:fillType="evenOdd"
- android:strokeWidth="1"
- android:pathData="M 6 10.4123279 L 8.63934949 10.4123279 L 8.63934949 15.6 L 12.5577168 7.84517705 L 9.94547194 7.84517705 L 9.94547194 2 Z" />
-</vector>
diff --git a/res/drawable/pending_widget_bg.xml b/res/drawable/pending_widget_bg.xml
new file mode 100644
index 0000000..cf29f90
--- /dev/null
+++ b/res/drawable/pending_widget_bg.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2017 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.
+-->
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:drawable="@drawable/round_rect_primary"
+ android:inset="@dimen/pending_widget_min_padding" />
diff --git a/res/layout/all_apps_discovery_item.xml b/res/layout/all_apps_discovery_item.xml
index 2b21ef5..1a7eaa7 100644
--- a/res/layout/all_apps_discovery_item.xml
+++ b/res/layout/all_apps_discovery_item.xml
@@ -27,18 +27,6 @@
android:padding="8dp"
android:scaleType="fitCenter"/>
- <ImageView
- android:id="@+id/badge"
- android:layout_width="16dp"
- android:layout_height="16dp"
- android:scaleType="fitCenter"
- android:src="@drawable/ic_instant_app"
- android:layout_marginRight="6dp"
- android:layout_marginBottom="6dp"
- android:layout_alignRight="@+id/image"
- android:layout_alignBottom="@+id/image"
- android:clickable="false"/>
-
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index 2a62037..9ec26e2 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -56,11 +56,10 @@
* Must not hold the Context.
*/
public AppInfo(Context context, LauncherActivityInfo info, UserHandle user) {
- this(context, info, user, UserManagerCompat.getInstance(context).isQuietModeEnabled(user));
+ this(info, user, UserManagerCompat.getInstance(context).isQuietModeEnabled(user));
}
- public AppInfo(Context context, LauncherActivityInfo info, UserHandle user,
- boolean quietModeEnabled) {
+ public AppInfo(LauncherActivityInfo info, UserHandle user, boolean quietModeEnabled) {
this.componentName = info.getComponentName();
this.container = ItemInfo.NO_ID;
this.user = user;
@@ -71,7 +70,7 @@
isDisabled |= ShortcutInfo.FLAG_DISABLED_QUIET_USER;
}
- intent = makeLaunchIntent(context, info, user);
+ intent = makeLaunchIntent(info);
}
public AppInfo(AppInfo info) {
@@ -95,14 +94,11 @@
return new ComponentKey(componentName, user);
}
- public static Intent makeLaunchIntent(Context context, LauncherActivityInfo info,
- UserHandle user) {
- long serialNumber = UserManagerCompat.getInstance(context).getSerialNumberForUser(user);
+ public static Intent makeLaunchIntent(LauncherActivityInfo info) {
return new Intent(Intent.ACTION_MAIN)
.addCategory(Intent.CATEGORY_LAUNCHER)
.setComponent(info.getComponentName())
- .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
- .putExtra(EXTRA_PROFILE, serialNumber);
+ .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
}
@Override
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 80dec16..ce85570 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -328,7 +328,7 @@
user = info.getUser();
mContext = context;
- launchIntent = AppInfo.makeLaunchIntent(context, info, user);
+ launchIntent = AppInfo.makeLaunchIntent(info);
label = info.getLabel().toString();
}
@@ -344,7 +344,7 @@
mContext = context;
user = info.getUserHandle();
- launchIntent = info.makeIntent(context);
+ launchIntent = info.makeIntent();
label = info.getShortLabel().toString();
}
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index aec6c7d..0779a3d 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -29,11 +29,6 @@
*/
public class ItemInfo {
- /**
- * Intent extra to store the profile. Format: UserHandle
- */
- public static final String EXTRA_PROFILE = "profile";
-
public static final int NO_ID = -1;
/**
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index b388d28..2dba83d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -483,7 +483,7 @@
// It's possible that All Apps is visible when this is run,
// so always use light status bar in that case. Only change nav bar color to status bar
// color when All Apps is visible.
- activateLightStatusBar(lightStatusBar || isAllAppsVisible(), isAllAppsVisible());
+ activateLightSystemBars(lightStatusBar || isAllAppsVisible(), true, isAllAppsVisible());
}
}
@@ -491,21 +491,26 @@
private static final int SYSTEM_UI_FLAG_LIGHT_NAV_BAR = 0x10;
/**
- * Sets the status bar to be light or not. Light status bar means dark icons.
- * @param lightStatusBar make sure the status bar is light
- * @param changeNavBar if true, make the nav bar theme in sync with status bar.
+ * Sets the status and/or nav bar to be light or not. Light status bar means dark icons.
+ * @param isLight make sure the system bar is light.
+ * @param statusBar if true, make the status bar theme match the isLight param.
+ * @param navBar if true, make the nav bar theme match the isLight param.
*/
- public void activateLightStatusBar(boolean lightStatusBar, boolean changeNavBar) {
+ public void activateLightSystemBars(boolean isLight, boolean statusBar, boolean navBar) {
int oldSystemUiFlags = getWindow().getDecorView().getSystemUiVisibility();
int newSystemUiFlags = oldSystemUiFlags;
- if (lightStatusBar) {
- newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR ;
- if (changeNavBar && Utilities.isAtLeastO()) {
+ if (isLight) {
+ if (statusBar) {
+ newSystemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
+ }
+ if (navBar && Utilities.isAtLeastO()) {
newSystemUiFlags |= SYSTEM_UI_FLAG_LIGHT_NAV_BAR;
}
} else {
- newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
- if (changeNavBar && Utilities.isAtLeastO()) {
+ if (statusBar) {
+ newSystemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
+ }
+ if (navBar && Utilities.isAtLeastO()) {
newSystemUiFlags &= ~(SYSTEM_UI_FLAG_LIGHT_NAV_BAR);
}
}
@@ -1451,9 +1456,14 @@
}
if (info == null) {
- info = InstallShortcutReceiver.fromShortcutIntent(this, data);
+ // Legacy shortcuts are only supported for primary profile.
+ info = Process.myUserHandle().equals(args.user)
+ ? InstallShortcutReceiver.fromShortcutIntent(this, data) : null;
- if (info == null || !new PackageManagerHelper(this).hasPermissionForActivity(
+ if (info == null) {
+ Log.e(TAG, "Unable to parse a valid custom shortcut result");
+ return;
+ } else if (!new PackageManagerHelper(this).hasPermissionForActivity(
info.intent, args.getPendingIntent().getComponent().getPackageName())) {
// The app is trying to add a shortcut without sufficient permissions
Log.e(TAG, "Ignoring malicious intent " + info.intent.toUri(0));
@@ -2696,11 +2706,7 @@
!intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
Bundle optsBundle = useLaunchAnimation ? getActivityLaunchOptions(v) : null;
- UserHandle user = null;
- if (intent.hasExtra(AppInfo.EXTRA_PROFILE)) {
- long serialNumber = intent.getLongExtra(AppInfo.EXTRA_PROFILE, -1);
- user = UserManagerCompat.getInstance(this).getUserForSerialNumber(serialNumber);
- }
+ UserHandle user = item == null ? null : item.user;
// Prepare intent
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index dc668e6..5a41eeb 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1069,9 +1069,6 @@
info.rank = c.getInt(rankIndex);
info.spanX = 1;
info.spanY = 1;
- // TODO: Remove this extra. Instead we should be using
- // itemInfo#user.
- info.intent.putExtra(ItemInfo.EXTRA_PROFILE, c.serialNumber);
info.isDisabled |= disabledState;
if (isSafeMode && !Utilities.isSystemApp(context, intent)) {
info.isDisabled |= ShortcutInfo.FLAG_DISABLED_SAFEMODE;
@@ -1685,7 +1682,7 @@
for (int i = 0; i < apps.size(); i++) {
LauncherActivityInfo app = apps.get(i);
// This builds the icon bitmaps.
- mBgAllAppsList.add(new AppInfo(mContext, app, user, quietMode), app);
+ mBgAllAppsList.add(new AppInfo(app, user, quietMode), app);
}
final ManagedProfileHeuristic heuristic = ManagedProfileHeuristic.get(mContext, user);
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index e250b3f..a750406 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -72,7 +72,7 @@
private static final String TAG = "LauncherProvider";
private static final boolean LOGD = false;
- private static final int DATABASE_VERSION = 27;
+ private static final int DATABASE_VERSION = 28;
public static final String AUTHORITY = ProviderConfig.AUTHORITY;
@@ -791,6 +791,26 @@
break;
}
case 27: {
+ // Remove "profile extra"
+ db.beginTransaction();
+ try {
+ UserManagerCompat um = UserManagerCompat.getInstance(mContext);
+ for (UserHandle user : um.getUserProfiles()) {
+ long serial = um.getSerialNumberForUser(user);
+ String sql = "update favorites set intent = replace(intent, "
+ + "';l.profile=" + serial + ";', ';') where itemType = 0;";
+ db.execSQL(sql);
+ }
+ db.setTransactionSuccessful();
+ } catch (SQLException ex) {
+ Log.e(TAG, ex.getMessage(), ex);
+ // Old version remains, which means we wipe old data
+ break;
+ } finally {
+ db.endTransaction();
+ }
+ }
+ case 28: {
// DB Upgraded successfully
return;
}
diff --git a/src/com/android/launcher3/PendingAppWidgetHostView.java b/src/com/android/launcher3/PendingAppWidgetHostView.java
index 43fa4aa..b163464 100644
--- a/src/com/android/launcher3/PendingAppWidgetHostView.java
+++ b/src/com/android/launcher3/PendingAppWidgetHostView.java
@@ -73,7 +73,7 @@
mPaint.setColor(Themes.getAttrColor(getContext(), android.R.attr.textColorPrimary));
mPaint.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX,
mLauncher.getDeviceProfile().iconTextSizePx, getResources().getDisplayMetrics()));
- setBackgroundResource(R.drawable.round_rect_primary);
+ setBackgroundResource(R.drawable.pending_widget_bg);
setWillNotDraw(false);
setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
diff --git a/src/com/android/launcher3/SessionCommitReceiver.java b/src/com/android/launcher3/SessionCommitReceiver.java
index e8bf0a5..203bc25 100644
--- a/src/com/android/launcher3/SessionCommitReceiver.java
+++ b/src/com/android/launcher3/SessionCommitReceiver.java
@@ -19,14 +19,17 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionInfo;
import android.os.Process;
import android.os.UserHandle;
import android.text.TextUtils;
+import android.util.Log;
import com.android.launcher3.compat.LauncherAppsCompat;
+import com.android.launcher3.compat.UserManagerCompat;
import java.util.List;
@@ -35,9 +38,13 @@
*/
public class SessionCommitReceiver extends BroadcastReceiver {
+ private static final long SESSION_IGNORE_DURATION = 3 * 60 * 60 * 1000; // 3 hours
+
// Preference key for automatically adding icon to homescreen.
public static final String ADD_ICON_PREFERENCE_KEY = "pref_add_icon_to_home";
+ private static final String KEY_FIRST_TIME = "first_session_broadcast_time";
+
@Override
public void onReceive(Context context, Intent intent) {
if (!isEnabled(context)) {
@@ -57,6 +64,17 @@
return;
}
+ // STOPSHIP: Remove this workaround when we start getting proper install reason
+ SharedPreferences prefs = context
+ .getSharedPreferences(LauncherFiles.DEVICE_PREFERENCES_KEY, 0);
+ long now = System.currentTimeMillis();
+ long firstTime = prefs.getLong(KEY_FIRST_TIME, now);
+ prefs.edit().putLong(KEY_FIRST_TIME, firstTime).apply();
+ if ((now - firstTime) < SESSION_IGNORE_DURATION) {
+ Log.d("SessionCommitReceiver", "Temporarily ignoring session broadcast");
+ return;
+ }
+
List<LauncherActivityInfo> activities = LauncherAppsCompat.getInstance(context)
.getActivityList(info.getAppPackageName(), user);
if (activities == null || activities.isEmpty()) {
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index f0bb1c0..6f0417c 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -199,7 +199,7 @@
public void updateFromDeepShortcutInfo(ShortcutInfoCompat shortcutInfo, Context context) {
// {@link ShortcutInfoCompat#getActivity} can change during an update. Recreate the intent
- intent = shortcutInfo.makeIntent(context);
+ intent = shortcutInfo.makeIntent();
title = shortcutInfo.getShortLabel();
CharSequence label = shortcutInfo.getLongLabel();
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index abc5367..207a7d4 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -468,13 +468,8 @@
&& TextUtils.isEmpty(launchIntent.getDataString())) {
// An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
Bundle extras = launchIntent.getExtras();
- if (extras == null) {
- return true;
- } else {
- Set<String> keys = extras.keySet();
- return keys.size() == 1 && keys.contains(ItemInfo.EXTRA_PROFILE);
- }
- };
+ return extras == null || extras.keySet().isEmpty();
+ }
return false;
}
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index b436fa2..30ed180 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -9,7 +9,6 @@
import android.graphics.Color;
import android.support.v4.graphics.ColorUtils;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
-import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
@@ -47,11 +46,10 @@
private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
private final Interpolator mDecelInterpolator = new DecelerateInterpolator(3f);
private final Interpolator mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
- private final ScrollInterpolator mScrollInterpolator = new ScrollInterpolator();
+ private final VerticalPullDetector.ScrollInterpolator mScrollInterpolator
+ = new VerticalPullDetector.ScrollInterpolator();
- private static final float ANIMATION_DURATION = 1200;
private static final float PARALLAX_COEFFICIENT = .125f;
- private static final float FAST_FLING_PX_MS = 10;
private static final int SINGLE_FRAME_MS = 16;
private AllAppsContainerView mAppsView;
@@ -262,7 +260,7 @@
// Use a light status bar (dark icons) if all apps is behind at least half of the status
// bar. If the status bar is already light due to wallpaper extraction, keep it that way.
boolean forceLight = shift <= mStatusBarHeight / 2;
- mLauncher.activateLightStatusBar(forceLight, true);
+ mLauncher.activateLightSystemBars(forceLight, true /* statusBar */, true /* navBar */);
}
/**
@@ -315,13 +313,7 @@
}
private void calculateDuration(float velocity, float disp) {
- // TODO: make these values constants after tuning.
- float velocityDivisor = Math.max(2f, Math.abs(0.5f * velocity));
- float travelDistance = Math.max(0.2f, disp / mShiftRange);
- mAnimationDuration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
- if (DBG) {
- Log.d(TAG, String.format("calculateDuration=%d, v=%f, d=%f", mAnimationDuration, velocity, disp));
- }
+ mAnimationDuration = mDetector.calculateDuration(velocity, disp / mShiftRange);
}
public boolean animateToAllApps(AnimatorSet animationOut, long duration) {
@@ -511,21 +503,4 @@
setProgress(mProgress);
}
- static class ScrollInterpolator implements Interpolator {
-
- boolean mSteeper;
-
- public void setVelocityAtZero(float velocity) {
- mSteeper = velocity > FAST_FLING_PX_MS;
- }
-
- public float getInterpolation(float t) {
- t -= 1.0f;
- float output = t * t * t;
- if (mSteeper) {
- output *= t * t; // Make interpolation initial slope steeper
- }
- return output + 1;
- }
- }
}
diff --git a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
index f228470..f5cf7ef 100644
--- a/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
+++ b/src/com/android/launcher3/allapps/AlphabeticalAppsList.java
@@ -292,7 +292,7 @@
mDiscoveredApps.clear();
break;
case UPDATE:
- mDiscoveredApps.add(new AppDiscoveryAppInfo(app, mLauncher));
+ mDiscoveredApps.add(new AppDiscoveryAppInfo(app));
break;
}
updateAdapterItems();
@@ -494,10 +494,13 @@
if (hasFilter()) {
if (isAppDiscoveryRunning() || mDiscoveredApps.size() > 0) {
mAdapterItems.add(AdapterItem.asLoadingDivider(position++));
-
// Append all app discovery results
for (int i = 0; i < mDiscoveredApps.size(); i++) {
AppDiscoveryAppInfo appDiscoveryAppInfo = mDiscoveredApps.get(i);
+ if (appDiscoveryAppInfo.isRecent) {
+ // already handled in getFilteredAppInfos()
+ continue;
+ }
AdapterItem item = AdapterItem.asDiscoveryItem(position++,
"", appDiscoveryAppInfo, appIndex++);
mAdapterItems.add(item);
@@ -589,6 +592,17 @@
result.add(match);
}
}
+
+ // adding recently used instant apps
+ if (mDiscoveredApps.size() > 0) {
+ for (int i = 0; i < mDiscoveredApps.size(); i++) {
+ AppDiscoveryAppInfo discoveryAppInfo = mDiscoveredApps.get(i);
+ if (discoveryAppInfo.isRecent) {
+ result.add(discoveryAppInfo);
+ }
+ }
+ Collections.sort(result, mAppNameComparator);
+ }
return result;
}
diff --git a/src/com/android/launcher3/allapps/VerticalPullDetector.java b/src/com/android/launcher3/allapps/VerticalPullDetector.java
index 96e1299..7800c01 100644
--- a/src/com/android/launcher3/allapps/VerticalPullDetector.java
+++ b/src/com/android/launcher3/allapps/VerticalPullDetector.java
@@ -4,6 +4,7 @@
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
+import android.view.animation.Interpolator;
/**
* One dimensional scroll gesture detector for all apps container pull up interaction.
@@ -23,6 +24,9 @@
public static final int DIRECTION_DOWN = 1 << 1;
public static final int DIRECTION_BOTH = DIRECTION_DOWN | DIRECTION_UP;
+ private static final float ANIMATION_DURATION = 1200;
+ private static final float FAST_FLING_PX_MS = 10;
+
/**
* The minimum release velocity in pixels per millisecond that triggers fling..
*/
@@ -112,7 +116,7 @@
mListener = l;
}
- interface Listener {
+ public interface Listener {
void onDragStart(boolean start);
boolean onDrag(float displacement, float velocity);
@@ -272,4 +276,33 @@
private static float interpolate(float from, float to, float alpha) {
return (1.0f - alpha) * from + alpha * to;
}
+
+ public long calculateDuration(float velocity, float progressNeeded) {
+ // TODO: make these values constants after tuning.
+ float velocityDivisor = Math.max(2f, Math.abs(0.5f * velocity));
+ float travelDistance = Math.max(0.2f, progressNeeded);
+ long duration = (long) Math.max(100, ANIMATION_DURATION / velocityDivisor * travelDistance);
+ if (DBG) {
+ Log.d(TAG, String.format("calculateDuration=%d, v=%f, d=%f", duration, velocity, progressNeeded));
+ }
+ return duration;
+ }
+
+ public static class ScrollInterpolator implements Interpolator {
+
+ boolean mSteeper;
+
+ public void setVelocityAtZero(float velocity) {
+ mSteeper = velocity > FAST_FLING_PX_MS;
+ }
+
+ public float getInterpolation(float t) {
+ t -= 1.0f;
+ float output = t * t * t;
+ if (mSteeper) {
+ output *= t * t; // Make interpolation initial slope steeper
+ }
+ return output + 1;
+ }
+ }
}
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVO.java b/src/com/android/launcher3/compat/LauncherAppsCompatVO.java
index 2743379..d7e35a2 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVO.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatVO.java
@@ -20,6 +20,8 @@
import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo;
import android.content.pm.LauncherApps;
+import android.os.Build;
+import android.os.Process;
import android.os.UserHandle;
import android.util.Log;
@@ -44,15 +46,20 @@
@Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList() {
List<ShortcutConfigActivityInfo> result = new ArrayList<>();
+ UserHandle myUser = Process.myUserHandle();
try {
Method m = LauncherApps.class.getDeclaredMethod("getShortcutConfigActivityList",
String.class, UserHandle.class);
for (UserHandle user : UserManagerCompat.getInstance(mContext).getUserProfiles()) {
+ boolean ignoreTargetSdk = myUser.equals(user);
List<LauncherActivityInfo> activities =
(List<LauncherActivityInfo>) m.invoke(mLauncherApps, null, user);
for (LauncherActivityInfo activityInfo : activities) {
- result.add(new ShortcutConfigActivityInfoVO(activityInfo));
+ if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >=
+ Build.VERSION_CODES.O) {
+ result.add(new ShortcutConfigActivityInfoVO(activityInfo));
+ }
}
}
} catch (Exception e) {
diff --git a/src/com/android/launcher3/compat/PinItemRequestCompat.java b/src/com/android/launcher3/compat/PinItemRequestCompat.java
index 550bcc3..1308cba 100644
--- a/src/com/android/launcher3/compat/PinItemRequestCompat.java
+++ b/src/com/android/launcher3/compat/PinItemRequestCompat.java
@@ -24,6 +24,8 @@
import android.os.Parcel;
import android.os.Parcelable;
+import com.android.launcher3.Utilities;
+
/**
* A wrapper around platform implementation of PinItemRequestCompat until the
* updated SDK is available.
@@ -115,6 +117,9 @@
};
public static PinItemRequestCompat getPinItemRequest(Intent intent) {
+ if (!Utilities.isAtLeastO()) {
+ return null;
+ }
Parcelable extra = intent.getParcelableExtra(EXTRA_PIN_ITEM_REQUEST);
return extra == null ? null : new PinItemRequestCompat(extra);
}
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java b/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java
index 50e979a..06493b2 100644
--- a/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java
+++ b/src/com/android/launcher3/discovery/AppDiscoveryAppInfo.java
@@ -18,24 +18,18 @@
import android.content.ComponentName;
import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.android.launcher3.AppInfo;
-import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings;
-import com.android.launcher3.R;
import com.android.launcher3.ShortcutInfo;
public class AppDiscoveryAppInfo extends AppInfo {
- private final @NonNull Launcher mLauncher;
-
public final boolean showAsDiscoveryItem;
public final boolean isInstantApp;
+ public final boolean isRecent;
public final float rating;
public final long reviewCount;
public final @NonNull String publisher;
@@ -43,14 +37,14 @@
public final @NonNull Intent launchIntent;
public final @Nullable String priceFormatted;
- public AppDiscoveryAppInfo(AppDiscoveryItem item, Launcher launcher) {
- this.mLauncher = launcher;
+ public AppDiscoveryAppInfo(AppDiscoveryItem item) {
this.intent = item.isInstantApp ? item.launchIntent : item.installIntent;
this.title = item.title;
this.iconBitmap = item.bitmap;
this.isDisabled = ShortcutInfo.DEFAULT;
this.usingLowResIcon = false;
this.isInstantApp = item.isInstantApp;
+ this.isRecent = item.isRecent;
this.rating = item.starRating;
this.showAsDiscoveryItem = true;
this.publisher = item.publisher != null ? item.publisher : "";
@@ -67,18 +61,7 @@
if (!isDragAndDropSupported()) {
throw new RuntimeException("DnD is currently not supported for discovered store apps");
}
- ShortcutInfo shortcutInfo = super.makeShortcut();
- if (isInstantApp) {
- int iconSize = iconBitmap.getWidth();
- int badgeSize = mLauncher.getResources().getDimensionPixelOffset(R.dimen.badge_size);
- Bitmap icon = Bitmap.createBitmap(iconBitmap);
- Drawable badgeDrawable = mLauncher.getDrawable(R.drawable.ic_instant_app);
- badgeDrawable.setBounds(iconSize - badgeSize, iconSize - badgeSize, iconSize, iconSize);
- Canvas canvas = new Canvas(icon);
- badgeDrawable.draw(canvas);
- shortcutInfo.iconBitmap = icon;
- }
- return shortcutInfo;
+ return super.makeShortcut();
}
public boolean isDragAndDropSupported() {
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItem.java b/src/com/android/launcher3/discovery/AppDiscoveryItem.java
index 7c10371..09c91ac 100644
--- a/src/com/android/launcher3/discovery/AppDiscoveryItem.java
+++ b/src/com/android/launcher3/discovery/AppDiscoveryItem.java
@@ -28,6 +28,7 @@
public final String packageName;
public final boolean isInstantApp;
+ public final boolean isRecent;
public final float starRating;
public final long reviewCount;
public final Intent launchIntent;
@@ -39,6 +40,7 @@
public AppDiscoveryItem(String packageName,
boolean isInstantApp,
+ boolean isRecent,
float starRating,
long reviewCount,
CharSequence title,
@@ -49,6 +51,7 @@
Intent installIntent) {
this.packageName = packageName;
this.isInstantApp = isInstantApp;
+ this.isRecent = isRecent;
this.starRating = starRating;
this.reviewCount = reviewCount;
this.launchIntent = launchIntent;
diff --git a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
index 6faad87..9bb3b10 100644
--- a/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
+++ b/src/com/android/launcher3/discovery/AppDiscoveryItemView.java
@@ -34,7 +34,6 @@
private static boolean SHOW_REVIEW_COUNT = false;
private ImageView mImage;
- private ImageView mBadge;
private TextView mTitle;
private TextView mRatingText;
private RatingView mRatingView;
@@ -58,7 +57,6 @@
protected void onFinishInflate() {
super.onFinishInflate();
this.mImage = (ImageView) findViewById(R.id.image);
- this.mBadge = (ImageView) findViewById(R.id.badge);
this.mTitle = (TextView) findViewById(R.id.title);
this.mRatingText = (TextView) findViewById(R.id.rating);
this.mRatingView = (RatingView) findViewById(R.id.rating_view);
@@ -80,7 +78,6 @@
mImage.setTag(info);
mImage.setImageBitmap(info.iconBitmap);
mImage.setOnLongClickListener(info.isDragAndDropSupported() ? mOnLongClickListener : null);
- mBadge.setVisibility(info.isInstantApp ? View.VISIBLE : View.GONE);
mTitle.setText(info.title);
mPrice.setText(info.priceFormatted != null ? info.priceFormatted : "");
mReviewCount.setVisibility(SHOW_REVIEW_COUNT ? View.VISIBLE : View.GONE);
diff --git a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
index dac2160..37047bb 100644
--- a/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
+++ b/src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java
@@ -44,15 +44,12 @@
}
@TargetApi(Build.VERSION_CODES.N)
- public Intent makeIntent(Context context) {
- long serialNumber = UserManagerCompat.getInstance(context)
- .getSerialNumberForUser(getUserHandle());
+ public Intent makeIntent() {
return new Intent(Intent.ACTION_MAIN)
.addCategory(INTENT_CATEGORY)
.setComponent(getActivity())
.setPackage(getPackage())
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
- .putExtra(ItemInfo.EXTRA_PROFILE, serialNumber)
.putExtra(EXTRA_SHORTCUT_ID, getId());
}
diff --git a/src/com/android/launcher3/util/ManagedProfileHeuristic.java b/src/com/android/launcher3/util/ManagedProfileHeuristic.java
index 85a000c..ce603c4 100644
--- a/src/com/android/launcher3/util/ManagedProfileHeuristic.java
+++ b/src/com/android/launcher3/util/ManagedProfileHeuristic.java
@@ -121,7 +121,7 @@
.isQuietModeEnabled(user);
for (int i = 0; i < count; i++) {
LauncherActivityInstallInfo info = apps.get(i);
- AppInfo appInfo = new AppInfo(mContext, info.info, user, quietModeEnabled);
+ AppInfo appInfo = new AppInfo(info.info, user, quietModeEnabled);
mIconCache.getTitleAndIcon(appInfo, info.info, false /* useLowResIcon */);
ShortcutInfo si = appInfo.makeShortcut();
((info.installTime <= folderCreationTime) ? workFolderApps : homescreenApps).add(si);
diff --git a/src/com/android/launcher3/util/PackageManagerHelper.java b/src/com/android/launcher3/util/PackageManagerHelper.java
index 7629f78..e12b2d4 100644
--- a/src/com/android/launcher3/util/PackageManagerHelper.java
+++ b/src/com/android/launcher3/util/PackageManagerHelper.java
@@ -76,7 +76,7 @@
public Intent getAppLaunchIntent(String pkg, UserHandle user) {
List<LauncherActivityInfo> activities = mLauncherApps.getActivityList(pkg, user);
return activities.isEmpty() ? null :
- AppInfo.makeLaunchIntent(mContext, activities.get(0), user);
+ AppInfo.makeLaunchIntent(activities.get(0));
}
/**
diff --git a/src/com/android/launcher3/util/PendingRequestArgs.java b/src/com/android/launcher3/util/PendingRequestArgs.java
index 538e1df..dabd40d 100644
--- a/src/com/android/launcher3/util/PendingRequestArgs.java
+++ b/src/com/android/launcher3/util/PendingRequestArgs.java
@@ -53,6 +53,7 @@
public PendingRequestArgs(Parcel parcel) {
readFromValues(ContentValues.CREATOR.createFromParcel(parcel));
+ user = parcel.readParcelable(null);
mArg1 = parcel.readInt();
mObjectType = parcel.readInt();
@@ -69,6 +70,7 @@
ContentValues itemValues = new ContentValues();
writeToValues(new ContentWriter(itemValues, null));
itemValues.writeToParcel(dest, flags);
+ dest.writeParcelable(user, flags);
dest.writeInt(mArg1);
dest.writeInt(mObjectType);