Removing all compatibility code below Lollipop
Bug: 32745285 Change-Id: I62971908e3e4402941fab627bbdfd47be64473a3
This commit is contained in:
parent
90a40570bc
commit
a52ecb0390
11
build.gradle
11
build.gradle
|
@ -12,12 +12,12 @@ apply plugin: 'com.android.application'
|
|||
apply plugin: 'com.google.protobuf'
|
||||
|
||||
android {
|
||||
compileSdkVersion 25
|
||||
compileSdkVersion 26
|
||||
buildToolsVersion '24.0.0'
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 25
|
||||
targetSdkVersion 26
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
|
@ -59,10 +59,11 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
final String SUPPORT_LIBS_VERSION = '26.0.0-SNAPSHOT'
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:23.1.1'
|
||||
compile 'com.android.support:recyclerview-v7:23.1.1'
|
||||
compile 'com.android.support:palette-v7:23.2.0'
|
||||
compile "com.android.support:support-v4:${SUPPORT_LIBS_VERSION}"
|
||||
compile "com.android.support:recyclerview-v7:${SUPPORT_LIBS_VERSION}"
|
||||
compile "com.android.support:palette-v7:${SUPPORT_LIBS_VERSION}"
|
||||
compile 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2'
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
|
|
|
@ -524,11 +524,7 @@ public class BubbleTextView extends TextView
|
|||
|
||||
protected void applyCompoundDrawables(Drawable icon) {
|
||||
if (mLayoutHorizontal) {
|
||||
if (Utilities.ATLEAST_JB_MR1) {
|
||||
setCompoundDrawablesRelative(icon, null, null, null);
|
||||
} else {
|
||||
setCompoundDrawables(icon, null, null, null);
|
||||
}
|
||||
setCompoundDrawablesRelative(icon, null, null, null);
|
||||
} else {
|
||||
setCompoundDrawables(null, icon, null, null);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.animation.FloatArrayEvaluator;
|
|||
import android.animation.ObjectAnimator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
|
@ -30,7 +29,6 @@ import android.graphics.ColorMatrix;
|
|||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -100,17 +98,11 @@ public abstract class ButtonDropTarget extends TextView
|
|||
mOriginalTextColor = getTextColors();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
protected void setDrawable(int resId) {
|
||||
// We do not set the drawable in the xml as that inflates two drawables corresponding to
|
||||
// drawableLeft and drawableStart.
|
||||
mDrawable = getResources().getDrawable(resId);
|
||||
|
||||
if (Utilities.ATLEAST_JB_MR1) {
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
|
||||
} else {
|
||||
setCompoundDrawablesWithIntrinsicBounds(mDrawable, null, null, null);
|
||||
}
|
||||
setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
|
||||
}
|
||||
|
||||
public void setDropTargetBar(DropTargetBar dropTargetBar) {
|
||||
|
@ -120,16 +112,7 @@ public abstract class ButtonDropTarget extends TextView
|
|||
@Override
|
||||
public final void onDragEnter(DragObject d) {
|
||||
d.dragView.setColor(mHoverColor);
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
animateTextColor(mHoverColor);
|
||||
} else {
|
||||
if (mCurrentFilter == null) {
|
||||
mCurrentFilter = new ColorMatrix();
|
||||
}
|
||||
DragView.setColorScale(mHoverColor, mCurrentFilter);
|
||||
mDrawable.setColorFilter(new ColorMatrixColorFilter(mCurrentFilter));
|
||||
setTextColor(mHoverColor);
|
||||
}
|
||||
animateTextColor(mHoverColor);
|
||||
if (d.stateAnnouncer != null) {
|
||||
d.stateAnnouncer.cancel();
|
||||
}
|
||||
|
@ -142,15 +125,9 @@ public abstract class ButtonDropTarget extends TextView
|
|||
}
|
||||
|
||||
protected void resetHoverColor() {
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
animateTextColor(mOriginalTextColor.getDefaultColor());
|
||||
} else {
|
||||
mDrawable.setColorFilter(null);
|
||||
setTextColor(mOriginalTextColor);
|
||||
}
|
||||
animateTextColor(mOriginalTextColor.getDefaultColor());
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void animateTextColor(int targetColor) {
|
||||
if (mCurrentColorAnim != null) {
|
||||
mCurrentColorAnim.cancel();
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.animation.AnimatorListenerAdapter;
|
|||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
|
@ -33,7 +32,6 @@ import android.graphics.Point;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
|
@ -297,7 +295,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
|
|||
addView(mShortcutsAndWidgets);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void enableAccessibleDrag(boolean enable, int dragType) {
|
||||
mUseTouchHelper = enable;
|
||||
if (!enable) {
|
||||
|
|
|
@ -44,7 +44,6 @@ import android.content.pm.ActivityInfo;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -69,7 +68,6 @@ import android.view.KeyboardShortcutGroup;
|
|||
import android.view.KeyboardShortcutInfo;
|
||||
import android.view.Menu;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.View.OnLongClickListener;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -89,7 +87,6 @@ import com.android.launcher3.allapps.AllAppsTransitionController;
|
|||
import com.android.launcher3.allapps.DefaultAppSearchController;
|
||||
import com.android.launcher3.anim.AnimationLayerSet;
|
||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||
import com.android.launcher3.compat.LauncherActivityInfoCompat;
|
||||
import com.android.launcher3.compat.LauncherAppsCompat;
|
||||
import com.android.launcher3.compat.UserManagerCompat;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
@ -1507,7 +1504,7 @@ public class Launcher extends Activity
|
|||
launcherInfo.spanY = itemInfo.spanY;
|
||||
launcherInfo.minSpanX = itemInfo.minSpanX;
|
||||
launcherInfo.minSpanY = itemInfo.minSpanY;
|
||||
launcherInfo.user = mAppWidgetManager.getUser(appWidgetInfo);
|
||||
launcherInfo.user = appWidgetInfo.getUser();
|
||||
|
||||
LauncherModel.addItemToDatabase(this, launcherInfo,
|
||||
itemInfo.container, itemInfo.screenId, itemInfo.cellX, itemInfo.cellY);
|
||||
|
@ -2090,7 +2087,7 @@ public class Launcher extends Activity
|
|||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE,
|
||||
mAppWidgetManager.getUser(info.info));
|
||||
info.info.getUser());
|
||||
// TODO: we need to make sure that this accounts for the options bundle.
|
||||
// intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
|
||||
startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
|
||||
|
@ -2324,7 +2321,7 @@ public class Launcher extends Activity
|
|||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, info.appWidgetId);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, appWidgetInfo.provider);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE,
|
||||
mAppWidgetManager.getUser(appWidgetInfo));
|
||||
appWidgetInfo.getUser());
|
||||
startActivityForResult(intent, REQUEST_BIND_PENDING_APPWIDGET);
|
||||
}
|
||||
} else {
|
||||
|
@ -3483,7 +3480,7 @@ public class Launcher extends Activity
|
|||
|
||||
// Also try to bind the widget. If the bind fails, the user will be shown
|
||||
// a click to setup UI, which will ask for the bind permission.
|
||||
PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(this, appWidgetInfo);
|
||||
PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(appWidgetInfo);
|
||||
pendingInfo.spanX = item.spanX;
|
||||
pendingInfo.spanY = item.spanY;
|
||||
pendingInfo.minSpanX = item.minSpanX;
|
||||
|
@ -3916,47 +3913,9 @@ public class Launcher extends Activity
|
|||
}
|
||||
}
|
||||
|
||||
private int mapConfigurationOriActivityInfoOri(int configOri) {
|
||||
final Display d = getWindowManager().getDefaultDisplay();
|
||||
int naturalOri = Configuration.ORIENTATION_LANDSCAPE;
|
||||
switch (d.getRotation()) {
|
||||
case Surface.ROTATION_0:
|
||||
case Surface.ROTATION_180:
|
||||
// We are currently in the same basic orientation as the natural orientation
|
||||
naturalOri = configOri;
|
||||
break;
|
||||
case Surface.ROTATION_90:
|
||||
case Surface.ROTATION_270:
|
||||
// We are currently in the other basic orientation to the natural orientation
|
||||
naturalOri = (configOri == Configuration.ORIENTATION_LANDSCAPE) ?
|
||||
Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
|
||||
break;
|
||||
}
|
||||
|
||||
int[] oriMap = {
|
||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
|
||||
ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
|
||||
ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT,
|
||||
ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE
|
||||
};
|
||||
// Since the map starts at portrait, we need to offset if this device's natural orientation
|
||||
// is landscape.
|
||||
int indexOffset = 0;
|
||||
if (naturalOri == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
indexOffset = 1;
|
||||
}
|
||||
return oriMap[(d.getRotation() + indexOffset) % 4];
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public void lockScreenOrientation() {
|
||||
if (mRotationEnabled) {
|
||||
if (Utilities.ATLEAST_JB_MR2) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
} else {
|
||||
setRequestedOrientation(mapConfigurationOriActivityInfoOri(getResources()
|
||||
.getConfiguration().orientation));
|
||||
}
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
@ -42,8 +41,6 @@ public class LauncherAppState {
|
|||
private final IconCache mIconCache;
|
||||
private final WidgetPreviewLoader mWidgetCache;
|
||||
|
||||
@Thunk boolean mWallpaperChangedSinceLastCheck;
|
||||
|
||||
private static WeakReference<LauncherProvider> sLauncherProvider;
|
||||
private static Context sContext;
|
||||
|
||||
|
@ -117,15 +114,6 @@ public class LauncherAppState {
|
|||
|
||||
sContext.registerReceiver(mModel, filter);
|
||||
UserManagerCompat.getInstance(sContext).enableAndResetCache();
|
||||
if (!Utilities.ATLEAST_KITKAT) {
|
||||
sContext.registerReceiver(new BroadcastReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mWallpaperChangedSinceLastCheck = true;
|
||||
}
|
||||
}, new IntentFilter(Intent.ACTION_WALLPAPER_CHANGED));
|
||||
}
|
||||
new ConfigMonitor(sContext).register();
|
||||
|
||||
ExtractionUtils.startColorExtractionServiceIfNecessary(sContext);
|
||||
|
@ -168,12 +156,6 @@ public class LauncherAppState {
|
|||
return mWidgetCache;
|
||||
}
|
||||
|
||||
public boolean hasWallpaperChangedSinceLastCheck() {
|
||||
boolean result = mWallpaperChangedSinceLastCheck;
|
||||
mWallpaperChangedSinceLastCheck = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
public InvariantDeviceProfile getInvariantDeviceProfile() {
|
||||
return mInvariantDeviceProfile;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.ComponentName;
|
||||
|
@ -9,8 +8,9 @@ import android.content.pm.PackageManager;
|
|||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
/**
|
||||
* This class is a thin wrapper around the framework AppWidgetProviderInfo class. This class affords
|
||||
|
@ -92,7 +92,6 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
|
|||
(minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public String getLabel(PackageManager packageManager) {
|
||||
if (isCustomWidget) {
|
||||
return Utilities.trim(label);
|
||||
|
@ -100,7 +99,6 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
|
|||
return super.loadLabel(packageManager);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public Drawable getIcon(Context context, IconCache cache) {
|
||||
if (isCustomWidget) {
|
||||
return cache.getFullResIcon(provider.getPackageName(), icon);
|
||||
|
@ -122,4 +120,8 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
|
|||
(resizeMode & RESIZE_HORIZONTAL) != 0 ? minSpanX : -1,
|
||||
(resizeMode & RESIZE_VERTICAL) != 0 ? minSpanY : -1);
|
||||
}
|
||||
|
||||
public UserHandle getUser() {
|
||||
return isCustomWidget ? Process.myUserHandle() : getProfile();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.appwidget.AppWidgetHost;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.ComponentName;
|
||||
|
@ -39,7 +38,6 @@ import android.database.sqlite.SQLiteQueryBuilder;
|
|||
import android.database.sqlite.SQLiteStatement;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
@ -534,13 +532,7 @@ public class LauncherProvider extends ContentProvider {
|
|||
*
|
||||
* @return the loader if the restrictions are set and the resource exists; null otherwise.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
private AutoInstallsLayout createWorkspaceLoaderFromAppRestriction(AppWidgetHost widgetHost) {
|
||||
// UserManager.getApplicationRestrictions() requires minSdkVersion >= 18
|
||||
if (!Utilities.ATLEAST_JB_MR2) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Context ctx = getContext();
|
||||
UserManager um = (UserManager) ctx.getSystemService(Context.USER_SERVICE);
|
||||
Bundle bundle = um.getApplicationRestrictions(ctx.getPackageName());
|
||||
|
|
|
@ -23,14 +23,10 @@ import android.animation.ObjectAnimator;
|
|||
import android.animation.PropertyValuesHolder;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import com.android.launcher3.allapps.AllAppsContainerView;
|
||||
import com.android.launcher3.allapps.AllAppsTransitionController;
|
||||
|
@ -229,7 +225,6 @@ public class LauncherStateTransitionAnimation {
|
|||
final boolean animated, int animType, final PrivateTransitionCallbacks pCb) {
|
||||
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
|
||||
final Resources res = mLauncher.getResources();
|
||||
final boolean material = Utilities.ATLEAST_LOLLIPOP;
|
||||
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
|
||||
final int revealDurationSlide = res.getInteger(R.integer.config_overlaySlideRevealTime);
|
||||
|
||||
|
@ -276,20 +271,11 @@ public class LauncherStateTransitionAnimation {
|
|||
revealView.setTranslationX(0f);
|
||||
|
||||
// Calculate the final animation values
|
||||
final float revealViewToAlpha;
|
||||
final float revealViewToXDrift;
|
||||
final float revealViewToYDrift;
|
||||
if (material) {
|
||||
int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(
|
||||
revealView, buttonView, null);
|
||||
revealViewToAlpha = pCb.materialRevealViewFinalAlpha;
|
||||
revealViewToYDrift = buttonViewToPanelDelta[1];
|
||||
revealViewToXDrift = buttonViewToPanelDelta[0];
|
||||
} else {
|
||||
revealViewToAlpha = 0f;
|
||||
revealViewToYDrift = 2 * height / 3;
|
||||
revealViewToXDrift = 0;
|
||||
}
|
||||
int[] buttonViewToPanelDelta =
|
||||
Utilities.getCenterDeltaInScreenSpace(revealView, buttonView);
|
||||
final float revealViewToAlpha = pCb.materialRevealViewFinalAlpha;
|
||||
final float revealViewToXDrift = buttonViewToPanelDelta[0];
|
||||
final float revealViewToYDrift = buttonViewToPanelDelta[1];
|
||||
|
||||
// Create the animators
|
||||
PropertyValuesHolder panelAlpha =
|
||||
|
@ -327,19 +313,17 @@ public class LauncherStateTransitionAnimation {
|
|||
itemsAlpha.setStartDelay(itemsAlphaStagger);
|
||||
animation.play(itemsAlpha);
|
||||
|
||||
if (material) {
|
||||
float startRadius = pCb.getMaterialRevealViewStartFinalRadius();
|
||||
AnimatorListenerAdapter listener = pCb.getMaterialRevealViewAnimatorListener(
|
||||
revealView, buttonView);
|
||||
Animator reveal = new CircleRevealOutlineProvider(width / 2, height / 2,
|
||||
startRadius, revealRadius).createRevealAnimator(revealView);
|
||||
reveal.setDuration(revealDuration);
|
||||
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
|
||||
if (listener != null) {
|
||||
reveal.addListener(listener);
|
||||
}
|
||||
animation.play(reveal);
|
||||
float startRadius = pCb.getMaterialRevealViewStartFinalRadius();
|
||||
AnimatorListenerAdapter listener = pCb.getMaterialRevealViewAnimatorListener(
|
||||
revealView, buttonView);
|
||||
Animator reveal = new CircleRevealOutlineProvider(width / 2, height / 2,
|
||||
startRadius, revealRadius).createRevealAnimator(revealView);
|
||||
reveal.setDuration(revealDuration);
|
||||
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
|
||||
if (listener != null) {
|
||||
reveal.addListener(listener);
|
||||
}
|
||||
animation.play(reveal);
|
||||
|
||||
animation.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
|
@ -531,11 +515,9 @@ public class LauncherStateTransitionAnimation {
|
|||
final PrivateTransitionCallbacks pCb) {
|
||||
final AnimatorSet animation = LauncherAnimUtils.createAnimatorSet();
|
||||
final Resources res = mLauncher.getResources();
|
||||
final boolean material = Utilities.ATLEAST_LOLLIPOP;
|
||||
final int revealDuration = res.getInteger(R.integer.config_overlayRevealTime);
|
||||
final int revealDurationSlide = res.getInteger(R.integer.config_overlaySlideRevealTime);
|
||||
final int itemsAlphaStagger =
|
||||
res.getInteger(R.integer.config_overlayItemsAlphaStagger);
|
||||
final int itemsAlphaStagger = res.getInteger(R.integer.config_overlayItemsAlphaStagger);
|
||||
|
||||
final View toView = mLauncher.getWorkspace();
|
||||
final View revealView = fromView.getRevealView();
|
||||
|
@ -579,24 +561,14 @@ public class LauncherStateTransitionAnimation {
|
|||
layerViews.addView(revealView);
|
||||
|
||||
// Calculate the final animation values
|
||||
final float revealViewToXDrift;
|
||||
final float revealViewToYDrift;
|
||||
if (material) {
|
||||
int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView,
|
||||
buttonView, null);
|
||||
revealViewToYDrift = buttonViewToPanelDelta[1];
|
||||
revealViewToXDrift = buttonViewToPanelDelta[0];
|
||||
} else {
|
||||
revealViewToYDrift = 2 * height / 3;
|
||||
revealViewToXDrift = 0;
|
||||
}
|
||||
int[] buttonViewToPanelDelta = Utilities.getCenterDeltaInScreenSpace(revealView, buttonView);
|
||||
final float revealViewToXDrift = buttonViewToPanelDelta[0];
|
||||
final float revealViewToYDrift = buttonViewToPanelDelta[1];
|
||||
|
||||
// The vertical motion of the apps panel should be delayed by one frame
|
||||
// from the conceal animation in order to give the right feel. We correspondingly
|
||||
// shorten the duration so that the slide and conceal end at the same time.
|
||||
TimeInterpolator decelerateInterpolator = material ?
|
||||
new LogDecelerateInterpolator(100, 0) :
|
||||
new DecelerateInterpolator(1f);
|
||||
TimeInterpolator decelerateInterpolator = new LogDecelerateInterpolator(100, 0);
|
||||
ObjectAnimator panelDriftY = ObjectAnimator.ofFloat(revealView, "translationY",
|
||||
0, revealViewToYDrift);
|
||||
panelDriftY.setDuration(revealDuration - SINGLE_FRAME_DELAY);
|
||||
|
@ -612,13 +584,10 @@ public class LauncherStateTransitionAnimation {
|
|||
animation.play(panelDriftX);
|
||||
|
||||
// Setup animation for the reveal panel alpha
|
||||
final float revealViewToAlpha = !material ? 0f :
|
||||
pCb.materialRevealViewFinalAlpha;
|
||||
if (revealViewToAlpha != 1f) {
|
||||
if (pCb.materialRevealViewFinalAlpha != 1f) {
|
||||
ObjectAnimator panelAlpha = ObjectAnimator.ofFloat(revealView, "alpha",
|
||||
1f, revealViewToAlpha);
|
||||
panelAlpha.setDuration(material ? revealDuration : 150);
|
||||
panelAlpha.setStartDelay(material ? 0 : itemsAlphaStagger + SINGLE_FRAME_DELAY);
|
||||
1f, pCb.materialRevealViewFinalAlpha);
|
||||
panelAlpha.setDuration(revealDuration);
|
||||
panelAlpha.setInterpolator(decelerateInterpolator);
|
||||
animation.play(panelAlpha);
|
||||
}
|
||||
|
@ -652,21 +621,19 @@ public class LauncherStateTransitionAnimation {
|
|||
});
|
||||
animation.play(invalidateScrim);
|
||||
|
||||
if (material) {
|
||||
// Animate the all apps button
|
||||
float finalRadius = pCb.getMaterialRevealViewStartFinalRadius();
|
||||
AnimatorListenerAdapter listener =
|
||||
pCb.getMaterialRevealViewAnimatorListener(revealView, buttonView);
|
||||
Animator reveal = new CircleRevealOutlineProvider(width / 2, height / 2,
|
||||
revealRadius, finalRadius).createRevealAnimator(revealView);
|
||||
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
|
||||
reveal.setDuration(revealDuration);
|
||||
reveal.setStartDelay(itemsAlphaStagger);
|
||||
if (listener != null) {
|
||||
reveal.addListener(listener);
|
||||
}
|
||||
animation.play(reveal);
|
||||
// Animate the all apps button
|
||||
float finalRadius = pCb.getMaterialRevealViewStartFinalRadius();
|
||||
AnimatorListenerAdapter listener =
|
||||
pCb.getMaterialRevealViewAnimatorListener(revealView, buttonView);
|
||||
Animator reveal = new CircleRevealOutlineProvider(width / 2, height / 2,
|
||||
revealRadius, finalRadius).createRevealAnimator(revealView);
|
||||
reveal.setInterpolator(new LogDecelerateInterpolator(100, 0));
|
||||
reveal.setDuration(revealDuration);
|
||||
reveal.setStartDelay(itemsAlphaStagger);
|
||||
if (listener != null) {
|
||||
reveal.addListener(listener);
|
||||
}
|
||||
animation.play(reveal);
|
||||
}
|
||||
|
||||
animation.addListener(new AnimatorListenerAdapter() {
|
||||
|
|
|
@ -22,13 +22,11 @@ import android.animation.LayoutTransition;
|
|||
import android.animation.ObjectAnimator;
|
||||
import android.animation.TimeInterpolator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
@ -2100,7 +2098,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
|||
|
||||
/* Accessibility */
|
||||
@SuppressWarnings("deprecation")
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
|
||||
super.onInitializeAccessibilityNodeInfo(info);
|
||||
|
@ -2117,9 +2114,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
|||
// Besides disabling the accessibility long-click, this also prevents this view from getting
|
||||
// accessibility focus.
|
||||
info.setLongClickable(false);
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
|
||||
}
|
||||
info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources.Theme;
|
||||
|
@ -26,7 +25,6 @@ import android.graphics.Color;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Layout;
|
||||
import android.text.StaticLayout;
|
||||
|
@ -63,7 +61,6 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
|
|||
private final TextPaint mPaint;
|
||||
private Layout mSetupTextLayout;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public PendingAppWidgetHostView(Context context, LauncherAppWidgetInfo info,
|
||||
IconCache cache, boolean disabledForSafeMode) {
|
||||
super(new ContextThemeWrapper(context, R.style.WidgetContainerTheme));
|
||||
|
@ -81,10 +78,7 @@ public class PendingAppWidgetHostView extends LauncherAppWidgetHostView implemen
|
|||
setBackgroundResource(R.drawable.quantum_panel_dark);
|
||||
setWillNotDraw(false);
|
||||
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
|
||||
}
|
||||
|
||||
setElevation(getResources().getDimension(R.dimen.pending_widget_elevation));
|
||||
updateIcon(cache);
|
||||
updateAppWidget(null);
|
||||
setOnClickListener(mLauncher);
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
@ -40,15 +38,12 @@ public class UninstallDropTarget extends ButtonDropTarget {
|
|||
return supportsDrop(getContext(), info);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
||||
public static boolean supportsDrop(Context context, Object info) {
|
||||
if (Utilities.ATLEAST_JB_MR2) {
|
||||
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
Bundle restrictions = userManager.getUserRestrictions();
|
||||
if (restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false)
|
||||
|| restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false)) {
|
||||
return false;
|
||||
}
|
||||
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
Bundle restrictions = userManager.getUserRestrictions();
|
||||
if (restrictions.getBoolean(UserManager.DISALLOW_APPS_CONTROL, false)
|
||||
|| restrictions.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return getUninstallTarget(context, info) != null;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.app.WallpaperManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
|
@ -105,18 +104,6 @@ public final class Utilities {
|
|||
public static final boolean ATLEAST_LOLLIPOP_MR1 =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1;
|
||||
|
||||
public static final boolean ATLEAST_LOLLIPOP =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
|
||||
public static final boolean ATLEAST_KITKAT =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
|
||||
|
||||
public static final boolean ATLEAST_JB_MR1 =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
|
||||
|
||||
public static final boolean ATLEAST_JB_MR2 =
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
|
||||
|
||||
// An intent extra to indicate the horizontal scroll of the wallpaper.
|
||||
public static final String EXTRA_WALLPAPER_OFFSET = "com.android.launcher3.WALLPAPER_OFFSET";
|
||||
|
||||
|
@ -229,7 +216,7 @@ public final class Utilities {
|
|||
localY < (v.getHeight() + slop);
|
||||
}
|
||||
|
||||
public static int[] getCenterDeltaInScreenSpace(View v0, View v1, int[] delta) {
|
||||
public static int[] getCenterDeltaInScreenSpace(View v0, View v1) {
|
||||
v0.getLocationInWindow(sLoc0);
|
||||
v1.getLocationInWindow(sLoc1);
|
||||
|
||||
|
@ -237,15 +224,7 @@ public final class Utilities {
|
|||
sLoc0[1] += (v0.getMeasuredHeight() * v0.getScaleY()) / 2;
|
||||
sLoc1[0] += (v1.getMeasuredWidth() * v1.getScaleX()) / 2;
|
||||
sLoc1[1] += (v1.getMeasuredHeight() * v1.getScaleY()) / 2;
|
||||
|
||||
if (delta == null) {
|
||||
delta = new int[2];
|
||||
}
|
||||
|
||||
delta[0] = sLoc1[0] - sLoc0[0];
|
||||
delta[1] = sLoc1[1] - sLoc0[1];
|
||||
|
||||
return delta;
|
||||
return new int[] {sLoc1[0] - sLoc0[0], sLoc1[1] - sLoc0[1]};
|
||||
}
|
||||
|
||||
public static void scaleRectAboutCenter(Rect r, float scale) {
|
||||
|
@ -479,10 +458,8 @@ public final class Utilities {
|
|||
System.out.println(b.toString());
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
public static boolean isRtl(Resources res) {
|
||||
return ATLEAST_JB_MR1 &&
|
||||
(res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
|
||||
return res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,16 +546,11 @@ public final class Utilities {
|
|||
* @param msg original message
|
||||
* @param ttsMsg message to be spoken
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static CharSequence wrapForTts(CharSequence msg, String ttsMsg) {
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
SpannableString spanned = new SpannableString(msg);
|
||||
spanned.setSpan(new TtsSpan.TextBuilder(ttsMsg).build(),
|
||||
0, spanned.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
return spanned;
|
||||
} else {
|
||||
return msg;
|
||||
}
|
||||
SpannableString spanned = new SpannableString(msg);
|
||||
spanned.setSpan(new TtsSpan.TextBuilder(ttsMsg).build(),
|
||||
0, spanned.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||
return spanned;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -593,10 +565,9 @@ public final class Utilities {
|
|||
LauncherFiles.SHARED_PREFERENCES_KEY, Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static boolean isPowerSaverOn(Context context) {
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
return ATLEAST_LOLLIPOP && powerManager.isPowerSaveMode();
|
||||
return powerManager.isPowerSaveMode();
|
||||
}
|
||||
|
||||
public static boolean isWallpaperAllowed(Context context) {
|
||||
|
|
|
@ -302,7 +302,7 @@ public class WidgetPreviewLoader {
|
|||
Drawable drawable = null;
|
||||
if (info.previewImage != 0) {
|
||||
try {
|
||||
drawable = mWidgetManager.loadPreview(info);
|
||||
drawable = info.loadPreviewImage(launcher.getApplicationContext(), 0);
|
||||
} catch (OutOfMemoryError e) {
|
||||
Log.w(TAG, "Error loading widget preview for: " + info.provider, e);
|
||||
// During OutOfMemoryError, the previous heap stack is not affected. Catching
|
||||
|
@ -395,7 +395,7 @@ public class WidgetPreviewLoader {
|
|||
float iconScale = Math.min((float) smallestSide / (appIconSize + 2 * minOffset), scale);
|
||||
|
||||
try {
|
||||
Drawable icon = mWidgetManager.loadIcon(info, mIconCache);
|
||||
Drawable icon = info.getIcon(launcher, mIconCache);
|
||||
if (icon != null) {
|
||||
icon = mutateOnMainThread(icon);
|
||||
int hoffset = (int) ((tileW - appIconSize * iconScale) / 2) + x;
|
||||
|
|
|
@ -1782,11 +1782,6 @@ public class Workspace extends PagedView
|
|||
}
|
||||
|
||||
protected void onResume() {
|
||||
// Update wallpaper dimensions if they were changed since last onResume
|
||||
// (we also always set the wallpaper dimensions in the constructor)
|
||||
if (LauncherAppState.getInstance().hasWallpaperChangedSinceLastCheck()) {
|
||||
setWallpaperDimension();
|
||||
}
|
||||
mWallpaperOffset.onResume();
|
||||
}
|
||||
|
||||
|
@ -2091,20 +2086,13 @@ public class Workspace extends PagedView
|
|||
public void updateAccessibilityFlags() {
|
||||
// TODO: Update the accessibility flags appropriately when dragging.
|
||||
if (!mLauncher.getAccessibilityDelegate().isInAccessibleDrag()) {
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
int total = getPageCount();
|
||||
for (int i = numCustomPages(); i < total; i++) {
|
||||
updateAccessibilityFlags((CellLayout) getPageAt(i), i);
|
||||
}
|
||||
setImportantForAccessibility((mState == State.NORMAL || mState == State.OVERVIEW)
|
||||
? IMPORTANT_FOR_ACCESSIBILITY_AUTO
|
||||
: IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
|
||||
} else {
|
||||
int accessible = mState == State.NORMAL ?
|
||||
IMPORTANT_FOR_ACCESSIBILITY_AUTO :
|
||||
IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS;
|
||||
setImportantForAccessibility(accessible);
|
||||
int total = getPageCount();
|
||||
for (int i = numCustomPages(); i < total; i++) {
|
||||
updateAccessibilityFlags((CellLayout) getPageAt(i), i);
|
||||
}
|
||||
setImportantForAccessibility((mState == State.NORMAL || mState == State.OVERVIEW)
|
||||
? IMPORTANT_FOR_ACCESSIBILITY_AUTO
|
||||
: IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package com.android.launcher3.accessibility;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.AlertDialog;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
|
@ -21,10 +19,7 @@ import com.android.launcher3.AppWidgetResizeFrame;
|
|||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.DeleteDropTarget;
|
||||
import com.android.launcher3.DragSource;
|
||||
import com.android.launcher3.DropTarget.DragObject;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.FolderInfo;
|
||||
import com.android.launcher3.InfoDropTarget;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
|
@ -39,13 +34,13 @@ import com.android.launcher3.ShortcutInfo;
|
|||
import com.android.launcher3.UninstallDropTarget;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.dragndrop.DragController.DragListener;
|
||||
import com.android.launcher3.shortcuts.DeepShortcutTextView;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.folder.Folder;
|
||||
import com.android.launcher3.shortcuts.DeepShortcutsContainer;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class LauncherAccessibilityDelegate extends AccessibilityDelegate implements DragListener {
|
||||
|
||||
private static final String TAG = "LauncherAccessibilityDelegate";
|
||||
|
|
|
@ -16,21 +16,19 @@
|
|||
|
||||
package com.android.launcher3.accessibility;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.SparseArray;
|
||||
import android.view.View;
|
||||
import android.view.View.AccessibilityDelegate;
|
||||
import android.view.accessibility.AccessibilityNodeInfo;
|
||||
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class OverviewScreenAccessibilityDelegate extends AccessibilityDelegate {
|
||||
|
||||
private static final int MOVE_BACKWARD = R.id.action_move_screen_backwards;
|
||||
|
|
|
@ -261,9 +261,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
|
|||
0, 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
|
||||
mSearchInput.setHint(spanned);
|
||||
|
||||
mElevationController = Utilities.ATLEAST_LOLLIPOP
|
||||
? new HeaderElevationController.ControllerVL(mSearchContainer)
|
||||
: new HeaderElevationController.ControllerV16(mSearchContainer);
|
||||
mElevationController = new HeaderElevationController(mSearchContainer);
|
||||
|
||||
// Load the all apps recycler view
|
||||
mAppsRecyclerView = (AllAppsRecyclerView) findViewById(R.id.apps_list_view);
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
package com.android.launcher3.allapps;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Build;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.android.launcher3.BaseRecyclerView;
|
||||
import com.android.launcher3.R;
|
||||
|
@ -19,10 +13,40 @@ import com.android.launcher3.Utilities;
|
|||
/**
|
||||
* Helper class for controlling the header elevation in response to RecyclerView scroll.
|
||||
*/
|
||||
public abstract class HeaderElevationController extends RecyclerView.OnScrollListener {
|
||||
public class HeaderElevationController extends RecyclerView.OnScrollListener {
|
||||
|
||||
private final View mHeader;
|
||||
private final float mMaxElevation;
|
||||
private final float mScrollToElevation;
|
||||
|
||||
private int mCurrentY = 0;
|
||||
|
||||
public HeaderElevationController(View header) {
|
||||
mHeader = header;
|
||||
final Resources res = mHeader.getContext().getResources();
|
||||
mMaxElevation = res.getDimension(R.dimen.all_apps_header_max_elevation);
|
||||
mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);
|
||||
|
||||
// We need to provide a custom outline so the shadow only appears on the bottom edge.
|
||||
// The top, left and right edges are all extended out, and the shadow is clipped
|
||||
// by the parent.
|
||||
final ViewOutlineProvider vop = new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
final View parent = (View) mHeader.getParent();
|
||||
|
||||
final int left = parent.getLeft(); // Use the parent to account for offsets
|
||||
final int top = view.getTop();
|
||||
final int right = left + view.getWidth();
|
||||
final int bottom = view.getBottom();
|
||||
|
||||
final int offset = Utilities.pxFromDp(mMaxElevation, res.getDisplayMetrics());
|
||||
outline.setRect(left - offset, top - offset, right + offset, bottom);
|
||||
}
|
||||
};
|
||||
mHeader.setOutlineProvider(vop);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
mCurrentY = 0;
|
||||
onScroll(mCurrentY);
|
||||
|
@ -34,88 +58,12 @@ public abstract class HeaderElevationController extends RecyclerView.OnScrollLis
|
|||
onScroll(mCurrentY);
|
||||
}
|
||||
|
||||
public void updateBackgroundPadding(Rect bgPadding) { }
|
||||
|
||||
abstract void onScroll(int scrollY);
|
||||
|
||||
public static class ControllerV16 extends HeaderElevationController {
|
||||
|
||||
private final View mShadow;
|
||||
private final float mScrollToElevation;
|
||||
|
||||
public ControllerV16(View header) {
|
||||
Resources res = header.getContext().getResources();
|
||||
mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);
|
||||
|
||||
mShadow = new View(header.getContext());
|
||||
mShadow.setBackground(new GradientDrawable(
|
||||
GradientDrawable.Orientation.TOP_BOTTOM, new int[] {0x1E000000, 0x00000000}));
|
||||
mShadow.setAlpha(0);
|
||||
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.MATCH_PARENT,
|
||||
res.getDimensionPixelSize(R.dimen.all_apps_header_shadow_height));
|
||||
lp.topMargin = ((FrameLayout.LayoutParams) header.getLayoutParams()).height;
|
||||
|
||||
((ViewGroup) header.getParent()).addView(mShadow, lp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(int scrollY) {
|
||||
float elevationPct = (float) Math.min(scrollY, mScrollToElevation) /
|
||||
mScrollToElevation;
|
||||
mShadow.setAlpha(elevationPct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBackgroundPadding(Rect bgPadding) {
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mShadow.getLayoutParams();
|
||||
lp.leftMargin = bgPadding.left;
|
||||
lp.rightMargin = bgPadding.right;
|
||||
mShadow.requestLayout();
|
||||
private void onScroll(int scrollY) {
|
||||
float elevationPct = Math.min(scrollY, mScrollToElevation) / mScrollToElevation;
|
||||
float newElevation = mMaxElevation * elevationPct;
|
||||
if (Float.compare(mHeader.getElevation(), newElevation) != 0) {
|
||||
mHeader.setElevation(newElevation);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static class ControllerVL extends HeaderElevationController {
|
||||
|
||||
private final View mHeader;
|
||||
private final float mMaxElevation;
|
||||
private final float mScrollToElevation;
|
||||
|
||||
public ControllerVL(View header) {
|
||||
mHeader = header;
|
||||
final Resources res = mHeader.getContext().getResources();
|
||||
mMaxElevation = res.getDimension(R.dimen.all_apps_header_max_elevation);
|
||||
mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);
|
||||
|
||||
// We need to provide a custom outline so the shadow only appears on the bottom edge.
|
||||
// The top, left and right edges are all extended out, and the shadow is clipped
|
||||
// by the parent.
|
||||
final ViewOutlineProvider vop = new ViewOutlineProvider() {
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline) {
|
||||
final View parent = (View) mHeader.getParent();
|
||||
|
||||
final int left = parent.getLeft(); // Use the parent to account for offsets
|
||||
final int top = view.getTop();
|
||||
final int right = left + view.getWidth();
|
||||
final int bottom = view.getBottom();
|
||||
|
||||
final int offset = Utilities.pxFromDp(mMaxElevation, res.getDisplayMetrics());
|
||||
outline.setRect(left - offset, top - offset, right + offset, bottom);
|
||||
}
|
||||
};
|
||||
mHeader.setOutlineProvider(vop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(int scrollY) {
|
||||
float elevationPct = Math.min(scrollY, mScrollToElevation) / mScrollToElevation;
|
||||
float newElevation = mMaxElevation * elevationPct;
|
||||
if (Float.compare(mHeader.getElevation(), newElevation) != 0) {
|
||||
mHeader.setElevation(newElevation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,10 @@ import android.appwidget.AppWidgetProviderInfo;
|
|||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.launcher3.IconCache;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -40,15 +37,10 @@ public abstract class AppWidgetManagerCompat {
|
|||
private static final Object sInstanceLock = new Object();
|
||||
private static AppWidgetManagerCompat sInstance;
|
||||
|
||||
|
||||
public static AppWidgetManagerCompat getInstance(Context context) {
|
||||
synchronized (sInstanceLock) {
|
||||
if (sInstance == null) {
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
sInstance = new AppWidgetManagerCompatVL(context.getApplicationContext());
|
||||
} else {
|
||||
sInstance = new AppWidgetManagerCompatV16(context.getApplicationContext());
|
||||
}
|
||||
sInstance = new AppWidgetManagerCompatVL(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
@ -73,20 +65,12 @@ public abstract class AppWidgetManagerCompat {
|
|||
|
||||
public abstract List<AppWidgetProviderInfo> getAllProviders();
|
||||
|
||||
public abstract String loadLabel(LauncherAppWidgetProviderInfo info);
|
||||
|
||||
public abstract boolean bindAppWidgetIdIfAllowed(
|
||||
int appWidgetId, AppWidgetProviderInfo info, Bundle options);
|
||||
|
||||
public abstract UserHandle getUser(LauncherAppWidgetProviderInfo info);
|
||||
|
||||
public abstract void startConfigActivity(AppWidgetProviderInfo info, int widgetId,
|
||||
Activity activity, AppWidgetHost host, int requestCode);
|
||||
|
||||
public abstract Drawable loadPreview(AppWidgetProviderInfo info);
|
||||
|
||||
public abstract Drawable loadIcon(LauncherAppWidgetProviderInfo info, IconCache cache);
|
||||
|
||||
public abstract Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
|
||||
int imageWidth, int imageHeight);
|
||||
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.appwidget.AppWidgetHost;
|
||||
import android.appwidget.AppWidgetManager;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.launcher3.IconCache;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
class AppWidgetManagerCompatV16 extends AppWidgetManagerCompat {
|
||||
|
||||
AppWidgetManagerCompatV16(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppWidgetProviderInfo> getAllProviders() {
|
||||
return mAppWidgetManager.getInstalledProviders();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loadLabel(LauncherAppWidgetProviderInfo info) {
|
||||
return Utilities.trim(info.label);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@Override
|
||||
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
|
||||
Bundle options) {
|
||||
if (Utilities.ATLEAST_JB_MR1) {
|
||||
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider, options);
|
||||
} else {
|
||||
return mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.provider);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserHandle getUser(LauncherAppWidgetProviderInfo info) {
|
||||
return Process.myUserHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startConfigActivity(AppWidgetProviderInfo info, int widgetId, Activity activity,
|
||||
AppWidgetHost host, int requestCode) {
|
||||
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_CONFIGURE);
|
||||
intent.setComponent(info.configure);
|
||||
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId);
|
||||
Utilities.startActivityForResultSafely(activity, intent, requestCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable loadPreview(AppWidgetProviderInfo info) {
|
||||
return mContext.getPackageManager().getDrawable(
|
||||
info.provider.getPackageName(), info.previewImage, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable loadIcon(LauncherAppWidgetProviderInfo info, IconCache cache) {
|
||||
return cache.getFullResIcon(info.provider.getPackageName(), info.icon);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
|
||||
int imageWidth, int imageHeight) {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherAppWidgetProviderInfo findProvider(
|
||||
ComponentName provider, UserHandle user) {
|
||||
for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
|
||||
if (info.provider.equals(provider)) {
|
||||
return LauncherAppWidgetProviderInfo.fromProviderInfo(mContext, info);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<ComponentKey, AppWidgetProviderInfo> getAllProvidersMap() {
|
||||
HashMap<ComponentKey, AppWidgetProviderInfo> result = new HashMap<>();
|
||||
UserHandle user = Process.myUserHandle();
|
||||
for (AppWidgetProviderInfo info : mAppWidgetManager.getInstalledProviders()) {
|
||||
result.put(new ComponentKey(info.provider, user), info);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.appwidget.AppWidgetHost;
|
||||
import android.appwidget.AppWidgetProviderInfo;
|
||||
|
@ -31,15 +30,12 @@ import android.graphics.Color;
|
|||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.IconCache;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
|
@ -48,7 +44,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
||||
|
||||
private final UserManager mUserManager;
|
||||
|
@ -69,11 +64,6 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
|||
return providers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String loadLabel(LauncherAppWidgetProviderInfo info) {
|
||||
return info.getLabel(mPm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
|
||||
Bundle options) {
|
||||
|
@ -81,14 +71,6 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
|||
appWidgetId, info.getProfile(), info.provider, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserHandle getUser(LauncherAppWidgetProviderInfo info) {
|
||||
if (info.isCustomWidget) {
|
||||
return Process.myUserHandle();
|
||||
}
|
||||
return info.getProfile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startConfigActivity(AppWidgetProviderInfo info, int widgetId, Activity activity,
|
||||
AppWidgetHost host, int requestCode) {
|
||||
|
@ -99,16 +81,6 @@ class AppWidgetManagerCompatVL extends AppWidgetManagerCompat {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable loadPreview(AppWidgetProviderInfo info) {
|
||||
return info.loadPreviewImage(mContext, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable loadIcon(LauncherAppWidgetProviderInfo info, IconCache cache) {
|
||||
return info.getIcon(mContext, cache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBadgeBitmap(LauncherAppWidgetProviderInfo info, Bitmap bitmap,
|
||||
int imageWidth, int imageHeight) {
|
||||
|
|
|
@ -1,98 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.compat;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
|
||||
public class LauncherActivityInfoCompatV16 extends LauncherActivityInfoCompat {
|
||||
private final ResolveInfo mResolveInfo;
|
||||
private final ActivityInfo mActivityInfo;
|
||||
private final ComponentName mComponentName;
|
||||
private final PackageManager mPm;
|
||||
|
||||
LauncherActivityInfoCompatV16(Context context, ResolveInfo info) {
|
||||
super();
|
||||
mResolveInfo = info;
|
||||
mActivityInfo = info.activityInfo;
|
||||
mComponentName = new ComponentName(mActivityInfo.packageName, mActivityInfo.name);
|
||||
mPm = context.getPackageManager();
|
||||
}
|
||||
|
||||
public ComponentName getComponentName() {
|
||||
return mComponentName;
|
||||
}
|
||||
|
||||
public UserHandle getUser() {
|
||||
return Process.myUserHandle();
|
||||
}
|
||||
|
||||
public CharSequence getLabel() {
|
||||
return mResolveInfo.loadLabel(mPm);
|
||||
}
|
||||
|
||||
public Drawable getIcon(int density) {
|
||||
int iconRes = mResolveInfo.getIconResource();
|
||||
Resources resources = null;
|
||||
Drawable icon = null;
|
||||
// Get the preferred density icon from the app's resources
|
||||
if (density != 0 && iconRes != 0) {
|
||||
try {
|
||||
resources = mPm.getResourcesForApplication(mActivityInfo.applicationInfo);
|
||||
icon = resources.getDrawableForDensity(iconRes, density);
|
||||
} catch (NameNotFoundException | Resources.NotFoundException exc) {
|
||||
}
|
||||
}
|
||||
// Get the default density icon
|
||||
if (icon == null) {
|
||||
icon = mResolveInfo.loadIcon(mPm);
|
||||
}
|
||||
if (icon == null) {
|
||||
resources = Resources.getSystem();
|
||||
icon = resources.getDrawableForDensity(android.R.mipmap.sym_def_app_icon, density);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public ApplicationInfo getApplicationInfo() {
|
||||
return mActivityInfo.applicationInfo;
|
||||
}
|
||||
|
||||
public long getFirstInstallTime() {
|
||||
try {
|
||||
PackageInfo info = mPm.getPackageInfo(mActivityInfo.packageName, 0);
|
||||
return info != null ? info.firstInstallTime : 0;
|
||||
} catch (NameNotFoundException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return mActivityInfo.name;
|
||||
}
|
||||
}
|
|
@ -16,15 +16,12 @@
|
|||
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.LauncherActivityInfo;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.UserHandle;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class LauncherActivityInfoCompatVL extends LauncherActivityInfoCompat {
|
||||
private LauncherActivityInfo mLauncherActivityInfo;
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ import android.graphics.Rect;
|
|||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -51,11 +50,7 @@ public abstract class LauncherAppsCompat {
|
|||
public static LauncherAppsCompat getInstance(Context context) {
|
||||
synchronized (sInstanceLock) {
|
||||
if (sInstance == null) {
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
sInstance = new LauncherAppsCompatVL(context.getApplicationContext());
|
||||
} else {
|
||||
sInstance = new LauncherAppsCompatV16(context.getApplicationContext());
|
||||
}
|
||||
sInstance = new LauncherAppsCompatVL(context.getApplicationContext());
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
@ -73,5 +68,4 @@ public abstract class LauncherAppsCompat {
|
|||
public abstract boolean isPackageEnabledForProfile(String packageName, UserHandle user);
|
||||
public abstract boolean isActivityEnabledForProfile(ComponentName component,
|
||||
UserHandle user);
|
||||
public abstract boolean isPackageSuspendedForProfile(String packageName, UserHandle user);
|
||||
}
|
||||
|
|
|
@ -1,218 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.compat;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.PackageManagerHelper;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Version of {@link LauncherAppsCompat} for devices with API level 16.
|
||||
* Devices Pre-L don't support multiple profiles in one launcher so
|
||||
* user parameters are ignored and all methods operate on the current user.
|
||||
*/
|
||||
public class LauncherAppsCompatV16 extends LauncherAppsCompat {
|
||||
|
||||
private PackageManager mPm;
|
||||
private Context mContext;
|
||||
private List<OnAppsChangedCallbackCompat> mCallbacks
|
||||
= new ArrayList<OnAppsChangedCallbackCompat>();
|
||||
private PackageMonitor mPackageMonitor;
|
||||
|
||||
LauncherAppsCompatV16(Context context) {
|
||||
mPm = context.getPackageManager();
|
||||
mContext = context;
|
||||
mPackageMonitor = new PackageMonitor();
|
||||
}
|
||||
|
||||
public List<LauncherActivityInfoCompat> getActivityList(String packageName,
|
||||
UserHandle user) {
|
||||
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
|
||||
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
mainIntent.setPackage(packageName);
|
||||
List<ResolveInfo> infos = mPm.queryIntentActivities(mainIntent, 0);
|
||||
List<LauncherActivityInfoCompat> list =
|
||||
new ArrayList<LauncherActivityInfoCompat>(infos.size());
|
||||
for (ResolveInfo info : infos) {
|
||||
list.add(new LauncherActivityInfoCompatV16(mContext, info));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public LauncherActivityInfoCompat resolveActivity(Intent intent, UserHandle user) {
|
||||
ResolveInfo info = mPm.resolveActivity(intent, 0);
|
||||
if (info != null) {
|
||||
return new LauncherActivityInfoCompatV16(mContext, info);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void startActivityForProfile(ComponentName component, UserHandle user,
|
||||
Rect sourceBounds, Bundle opts) {
|
||||
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
|
||||
launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launchIntent.setComponent(component);
|
||||
launchIntent.setSourceBounds(sourceBounds);
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
mContext.startActivity(launchIntent, opts);
|
||||
}
|
||||
|
||||
public void showAppDetailsForProfile(ComponentName component, UserHandle user) {
|
||||
String packageName = component.getPackageName();
|
||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
|
||||
Uri.fromParts("package", packageName, null));
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK |
|
||||
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
|
||||
mContext.startActivity(intent, null);
|
||||
}
|
||||
|
||||
public synchronized void addOnAppsChangedCallback(OnAppsChangedCallbackCompat callback) {
|
||||
if (callback != null && !mCallbacks.contains(callback)) {
|
||||
mCallbacks.add(callback);
|
||||
if (mCallbacks.size() == 1) {
|
||||
registerForPackageIntents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat callback) {
|
||||
mCallbacks.remove(callback);
|
||||
if (mCallbacks.size() == 0) {
|
||||
unregisterForPackageIntents();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPackageEnabledForProfile(String packageName, UserHandle user) {
|
||||
return PackageManagerHelper.isAppEnabled(mPm, packageName);
|
||||
}
|
||||
|
||||
public boolean isActivityEnabledForProfile(ComponentName component, UserHandle user) {
|
||||
try {
|
||||
ActivityInfo info = mPm.getActivityInfo(component, 0);
|
||||
return info != null && info.isEnabled();
|
||||
} catch (NameNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPackageSuspendedForProfile(String packageName, UserHandle user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void unregisterForPackageIntents() {
|
||||
mContext.unregisterReceiver(mPackageMonitor);
|
||||
}
|
||||
|
||||
private void registerForPackageIntents() {
|
||||
IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||
filter.addDataScheme("package");
|
||||
mContext.registerReceiver(mPackageMonitor, filter);
|
||||
filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE);
|
||||
filter.addAction(Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE);
|
||||
mContext.registerReceiver(mPackageMonitor, filter);
|
||||
}
|
||||
|
||||
@Thunk synchronized List<OnAppsChangedCallbackCompat> getCallbacks() {
|
||||
return new ArrayList<OnAppsChangedCallbackCompat>(mCallbacks);
|
||||
}
|
||||
|
||||
@Thunk class PackageMonitor extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
final String action = intent.getAction();
|
||||
final UserHandle user = Process.myUserHandle();
|
||||
|
||||
if (Intent.ACTION_PACKAGE_CHANGED.equals(action)
|
||||
|| Intent.ACTION_PACKAGE_REMOVED.equals(action)
|
||||
|| Intent.ACTION_PACKAGE_ADDED.equals(action)) {
|
||||
final String packageName = intent.getData().getSchemeSpecificPart();
|
||||
final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
||||
|
||||
if (packageName == null || packageName.length() == 0) {
|
||||
// they sent us a bad intent
|
||||
return;
|
||||
}
|
||||
if (Intent.ACTION_PACKAGE_CHANGED.equals(action)) {
|
||||
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
|
||||
callback.onPackageChanged(packageName, user);
|
||||
}
|
||||
} else if (Intent.ACTION_PACKAGE_REMOVED.equals(action)) {
|
||||
if (!replacing) {
|
||||
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
|
||||
callback.onPackageRemoved(packageName, user);
|
||||
}
|
||||
}
|
||||
// else, we are replacing the package, so a PACKAGE_ADDED will be sent
|
||||
// later, we will update the package at this time
|
||||
} else if (Intent.ACTION_PACKAGE_ADDED.equals(action)) {
|
||||
if (!replacing) {
|
||||
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
|
||||
callback.onPackageAdded(packageName, user);
|
||||
}
|
||||
} else {
|
||||
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
|
||||
callback.onPackageChanged(packageName, user);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE.equals(action)) {
|
||||
// EXTRA_REPLACING is available Kitkat onwards. For lower devices, it is broadcasted
|
||||
// when moving a package or mounting/un-mounting external storage. Assume that
|
||||
// it is a replacing operation.
|
||||
final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING,
|
||||
!Utilities.ATLEAST_KITKAT);
|
||||
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
|
||||
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
|
||||
callback.onPackagesAvailable(packages, user, replacing);
|
||||
}
|
||||
} else if (Intent.ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE.equals(action)) {
|
||||
// This intent is broadcasted when moving a package or mounting/un-mounting
|
||||
// external storage.
|
||||
// However on Kitkat this is also sent when a package is being updated, and
|
||||
// contains an extra Intent.EXTRA_REPLACING=true for that case.
|
||||
// Using false as default for Intent.EXTRA_REPLACING gives correct value on
|
||||
// lower devices as the intent is not sent when the app is updating/replacing.
|
||||
final boolean replacing = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
||||
String[] packages = intent.getStringArrayExtra(Intent.EXTRA_CHANGED_PACKAGE_LIST);
|
||||
for (OnAppsChangedCallbackCompat callback : getCallbacks()) {
|
||||
callback.onPackagesUnavailable(packages, user, replacing);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -24,7 +23,6 @@ import android.content.pm.LauncherActivityInfo;
|
|||
import android.content.pm.LauncherApps;
|
||||
import android.content.pm.ShortcutInfo;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
|
||||
|
@ -36,32 +34,30 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class LauncherAppsCompatVL extends LauncherAppsCompatV16 {
|
||||
public class LauncherAppsCompatVL extends LauncherAppsCompat {
|
||||
|
||||
protected LauncherApps mLauncherApps;
|
||||
|
||||
private Map<OnAppsChangedCallbackCompat, WrappedCallback> mCallbacks
|
||||
= new HashMap<OnAppsChangedCallbackCompat, WrappedCallback>();
|
||||
private Map<OnAppsChangedCallbackCompat, WrappedCallback> mCallbacks = new HashMap<>();
|
||||
|
||||
LauncherAppsCompatVL(Context context) {
|
||||
super(context);
|
||||
mLauncherApps = (LauncherApps) context.getSystemService("launcherapps");
|
||||
mLauncherApps = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LauncherActivityInfoCompat> getActivityList(String packageName, UserHandle user) {
|
||||
List<LauncherActivityInfo> list = mLauncherApps.getActivityList(packageName, user);
|
||||
if (list.size() == 0) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ArrayList<LauncherActivityInfoCompat> compatList =
|
||||
new ArrayList<LauncherActivityInfoCompat>(list.size());
|
||||
ArrayList<LauncherActivityInfoCompat> compatList = new ArrayList<>(list.size());
|
||||
for (LauncherActivityInfo info : list) {
|
||||
compatList.add(new LauncherActivityInfoCompatVL(info));
|
||||
}
|
||||
return compatList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherActivityInfoCompat resolveActivity(Intent intent, UserHandle user) {
|
||||
LauncherActivityInfo activity = mLauncherApps.resolveActivity(intent, user);
|
||||
if (activity != null) {
|
||||
|
@ -71,15 +67,18 @@ public class LauncherAppsCompatVL extends LauncherAppsCompatV16 {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startActivityForProfile(ComponentName component, UserHandle user,
|
||||
Rect sourceBounds, Bundle opts) {
|
||||
mLauncherApps.startMainActivity(component, user, sourceBounds, opts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showAppDetailsForProfile(ComponentName component, UserHandle user) {
|
||||
mLauncherApps.startAppDetailsActivity(component, user, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOnAppsChangedCallback(LauncherAppsCompat.OnAppsChangedCallbackCompat callback) {
|
||||
WrappedCallback wrappedCallback = new WrappedCallback(callback);
|
||||
synchronized (mCallbacks) {
|
||||
|
@ -88,9 +87,9 @@ public class LauncherAppsCompatVL extends LauncherAppsCompatV16 {
|
|||
mLauncherApps.registerCallback(wrappedCallback);
|
||||
}
|
||||
|
||||
public void removeOnAppsChangedCallback(
|
||||
LauncherAppsCompat.OnAppsChangedCallbackCompat callback) {
|
||||
WrappedCallback wrappedCallback = null;
|
||||
@Override
|
||||
public void removeOnAppsChangedCallback(OnAppsChangedCallbackCompat callback) {
|
||||
final WrappedCallback wrappedCallback;
|
||||
synchronized (mCallbacks) {
|
||||
wrappedCallback = mCallbacks.remove(callback);
|
||||
}
|
||||
|
@ -99,18 +98,16 @@ public class LauncherAppsCompatVL extends LauncherAppsCompatV16 {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackageEnabledForProfile(String packageName, UserHandle user) {
|
||||
return mLauncherApps.isPackageEnabled(packageName, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActivityEnabledForProfile(ComponentName component, UserHandle user) {
|
||||
return mLauncherApps.isActivityEnabled(component, user);
|
||||
}
|
||||
|
||||
public boolean isPackageSuspendedForProfile(String packageName, UserHandle user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static class WrappedCallback extends LauncherApps.Callback {
|
||||
private LauncherAppsCompat.OnAppsChangedCallbackCompat mCallback;
|
||||
|
||||
|
@ -147,7 +144,6 @@ public class LauncherAppsCompatVL extends LauncherAppsCompatV16 {
|
|||
mCallback.onPackagesUnsuspended(packageNames, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShortcutsChanged(String packageName, List<ShortcutInfo> shortcuts,
|
||||
UserHandle user) {
|
||||
List<ShortcutInfoCompat> shortcutInfoCompats = new ArrayList<>(shortcuts.size());
|
||||
|
|
|
@ -18,8 +18,6 @@ package com.android.launcher3.compat;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public abstract class PackageInstallerCompat {
|
||||
|
@ -34,11 +32,7 @@ public abstract class PackageInstallerCompat {
|
|||
public static PackageInstallerCompat getInstance(Context context) {
|
||||
synchronized (sInstanceLock) {
|
||||
if (sInstance == null) {
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
sInstance = new PackageInstallerCompatVL(context);
|
||||
} else {
|
||||
sInstance = new PackageInstallerCompatV16();
|
||||
}
|
||||
sInstance = new PackageInstallerCompatVL(context);
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.compat;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class PackageInstallerCompatV16 extends PackageInstallerCompat {
|
||||
|
||||
PackageInstallerCompatV16() { }
|
||||
|
||||
@Override
|
||||
public void onStop() { }
|
||||
|
||||
@Override
|
||||
public HashMap<String, Integer> updateAndGetActiveSessionCache() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
|
@ -16,12 +16,10 @@
|
|||
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.pm.PackageInstaller.SessionCallback;
|
||||
import android.content.pm.PackageInstaller.SessionInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
@ -34,7 +32,6 @@ import com.android.launcher3.util.Thunk;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class PackageInstallerCompatVL extends PackageInstallerCompat {
|
||||
|
||||
@Thunk final SparseArray<String> mActiveSessions = new SparseArray<>();
|
||||
|
|
|
@ -39,12 +39,8 @@ public abstract class UserManagerCompat {
|
|||
sInstance = new UserManagerCompatVN(context.getApplicationContext());
|
||||
} else if (Utilities.ATLEAST_MARSHMALLOW) {
|
||||
sInstance = new UserManagerCompatVM(context.getApplicationContext());
|
||||
} else if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
sInstance = new UserManagerCompatVL(context.getApplicationContext());
|
||||
} else if (Utilities.ATLEAST_JB_MR1) {
|
||||
sInstance = new UserManagerCompatV17(context.getApplicationContext());
|
||||
} else {
|
||||
sInstance = new UserManagerCompatV16();
|
||||
sInstance = new UserManagerCompatVL(context.getApplicationContext());
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.compat;
|
||||
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserManagerCompatV16 extends UserManagerCompat {
|
||||
|
||||
UserManagerCompatV16() {
|
||||
}
|
||||
|
||||
public List<UserHandle> getUserProfiles() {
|
||||
List<UserHandle> profiles = new ArrayList<UserHandle>(1);
|
||||
profiles.add(Process.myUserHandle());
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public UserHandle getUserForSerialNumber(long serialNumber) {
|
||||
return Process.myUserHandle();
|
||||
}
|
||||
|
||||
public long getSerialNumberForUser(UserHandle user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public CharSequence getBadgedLabelForUser(CharSequence label, UserHandle user) {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getUserCreationTime(UserHandle user) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndResetCache() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuietModeEnabled(UserHandle user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserUnlocked(UserHandle user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDemoUser() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2014 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.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.launcher3.util.LongArrayMap;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
public class UserManagerCompatV17 extends UserManagerCompatV16 {
|
||||
|
||||
protected LongArrayMap<UserHandle> mUsers;
|
||||
// Create a separate reverse map as LongArrayMap.indexOfValue checks if objects are same
|
||||
// and not {@link Object#equals}
|
||||
protected HashMap<UserHandle, Long> mUserToSerialMap;
|
||||
|
||||
protected UserManager mUserManager;
|
||||
|
||||
UserManagerCompatV17(Context context) {
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
}
|
||||
|
||||
public long getSerialNumberForUser(UserHandle user) {
|
||||
synchronized (this) {
|
||||
if (mUserToSerialMap != null) {
|
||||
Long serial = mUserToSerialMap.get(user);
|
||||
return serial == null ? 0 : serial;
|
||||
}
|
||||
}
|
||||
return mUserManager.getSerialNumberForUser(user);
|
||||
}
|
||||
|
||||
public UserHandle getUserForSerialNumber(long serialNumber) {
|
||||
synchronized (this) {
|
||||
if (mUsers != null) {
|
||||
return mUsers.get(serialNumber);
|
||||
}
|
||||
}
|
||||
return mUserManager.getUserForSerialNumber(serialNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndResetCache() {
|
||||
synchronized (this) {
|
||||
mUsers = new LongArrayMap<>();
|
||||
mUserToSerialMap = new HashMap<>();
|
||||
UserHandle myUser = Process.myUserHandle();
|
||||
long serial = mUserManager.getSerialNumberForUser(myUser);
|
||||
mUsers.put(serial, myUser);
|
||||
mUserToSerialMap.put(myUser, serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,12 +16,11 @@
|
|||
|
||||
package com.android.launcher3.compat;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Build;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.LongArrayMap;
|
||||
|
@ -31,19 +30,60 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class UserManagerCompatVL extends UserManagerCompatV17 {
|
||||
public class UserManagerCompatVL extends UserManagerCompat {
|
||||
private static final String USER_CREATION_TIME_KEY = "user_creation_time_";
|
||||
|
||||
protected final UserManager mUserManager;
|
||||
private final PackageManager mPm;
|
||||
private final Context mContext;
|
||||
|
||||
protected LongArrayMap<UserHandle> mUsers;
|
||||
// Create a separate reverse map as LongArrayMap.indexOfValue checks if objects are same
|
||||
// and not {@link Object#equals}
|
||||
protected HashMap<UserHandle, Long> mUserToSerialMap;
|
||||
|
||||
UserManagerCompatVL(Context context) {
|
||||
super(context);
|
||||
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
|
||||
mPm = context.getPackageManager();
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSerialNumberForUser(UserHandle user) {
|
||||
synchronized (this) {
|
||||
if (mUserToSerialMap != null) {
|
||||
Long serial = mUserToSerialMap.get(user);
|
||||
return serial == null ? 0 : serial;
|
||||
}
|
||||
}
|
||||
return mUserManager.getSerialNumberForUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserHandle getUserForSerialNumber(long serialNumber) {
|
||||
synchronized (this) {
|
||||
if (mUsers != null) {
|
||||
return mUsers.get(serialNumber);
|
||||
}
|
||||
}
|
||||
return mUserManager.getUserForSerialNumber(serialNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isQuietModeEnabled(UserHandle user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUserUnlocked(UserHandle user) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDemoUser() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAndResetCache() {
|
||||
synchronized (this) {
|
||||
|
|
|
@ -22,7 +22,6 @@ import android.animation.FloatArrayEvaluator;
|
|||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
|
@ -31,14 +30,12 @@ import android.graphics.ColorMatrixColorFilter;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAnimUtils;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.util.Thunk;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -88,7 +85,6 @@ public class DragView extends View {
|
|||
* @param registrationX The x coordinate of the registration point.
|
||||
* @param registrationY The y coordinate of the registration point.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY,
|
||||
final float initialScale, final float finalScaleDps) {
|
||||
super(launcher);
|
||||
|
@ -144,9 +140,7 @@ public class DragView extends View {
|
|||
measure(ms, ms);
|
||||
mPaint = new Paint(Paint.FILTER_BITMAP_FLAG);
|
||||
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
setElevation(getResources().getDimension(R.dimen.drag_elevation));
|
||||
}
|
||||
setElevation(getResources().getDimension(R.dimen.drag_elevation));
|
||||
}
|
||||
|
||||
/** Sets the scale of the view over the normal workspace icon size. */
|
||||
|
@ -265,14 +259,9 @@ public class DragView extends View {
|
|||
setColorScale(color, m2);
|
||||
m1.postConcat(m2);
|
||||
|
||||
if (Utilities.ATLEAST_LOLLIPOP) {
|
||||
animateFilterTo(m1.getArray());
|
||||
} else {
|
||||
mPaint.setColorFilter(new ColorMatrixColorFilter(m1));
|
||||
invalidate();
|
||||
}
|
||||
animateFilterTo(m1.getArray());
|
||||
} else {
|
||||
if (!Utilities.ATLEAST_LOLLIPOP || mCurrentFilter == null) {
|
||||
if (mCurrentFilter == null) {
|
||||
mPaint.setColorFilter(null);
|
||||
invalidate();
|
||||
} else {
|
||||
|
@ -281,7 +270,6 @@ public class DragView extends View {
|
|||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
private void animateFilterTo(float[] targetFilter) {
|
||||
float[] oldFilter = mCurrentFilter == null ? new ColorMatrix().getArray() : mCurrentFilter;
|
||||
mCurrentFilter = Arrays.copyOf(oldFilter, oldFilter.length);
|
||||
|
|
|
@ -22,11 +22,9 @@ import android.animation.AnimatorSet;
|
|||
import android.animation.ObjectAnimator;
|
||||
import android.animation.PropertyValuesHolder;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.text.InputType;
|
||||
import android.text.Selection;
|
||||
import android.util.AttributeSet;
|
||||
|
@ -643,10 +641,8 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
|
|||
public void onAnimationEnd(Animator animation) {
|
||||
mFolderName.animate().setDuration(FOLDER_NAME_ANIMATION_DURATION)
|
||||
.translationX(0)
|
||||
.setInterpolator(Utilities.ATLEAST_LOLLIPOP ?
|
||||
AnimationUtils.loadInterpolator(mLauncher,
|
||||
android.R.interpolator.fast_out_slow_in)
|
||||
: new LogDecelerateInterpolator(100, 0));
|
||||
.setInterpolator(AnimationUtils.loadInterpolator(
|
||||
mLauncher, android.R.interpolator.fast_out_slow_in));
|
||||
mPageIndicator.playEntryAnimation();
|
||||
|
||||
if (updateAnimationFlag) {
|
||||
|
@ -789,7 +785,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
|
|||
}
|
||||
};
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
public boolean isLayoutRtl() {
|
||||
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package com.android.launcher3.graphics;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent.ShortcutIconResource;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -32,13 +31,11 @@ import android.graphics.RectF;
|
|||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.PaintDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Process;
|
||||
import android.os.UserHandle;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
|
||||
/**
|
||||
|
@ -104,7 +101,6 @@ public class LauncherIcons {
|
|||
* Returns a bitmap suitable for the all apps view. The icon is badged for {@param user}.
|
||||
* The bitmap is also visually normalized with other icons.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static Bitmap createBadgedIconBitmap(
|
||||
Drawable icon, UserHandle user, Context context) {
|
||||
float scale = FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ?
|
||||
|
@ -117,8 +113,7 @@ public class LauncherIcons {
|
|||
* Badges the provided icon with the user badge if required.
|
||||
*/
|
||||
public static Bitmap badgeIconForUser(Bitmap icon, UserHandle user, Context context) {
|
||||
if (Utilities.ATLEAST_LOLLIPOP && user != null
|
||||
&& !Process.myUserHandle().equals(user)) {
|
||||
if (user != null && !Process.myUserHandle().equals(user)) {
|
||||
BitmapDrawable drawable = new FixedSizeBitmapDrawable(icon);
|
||||
Drawable badged = context.getPackageManager().getUserBadgedIcon(
|
||||
drawable, user);
|
||||
|
@ -155,7 +150,6 @@ public class LauncherIcons {
|
|||
/**
|
||||
* Adds the {@param badge} on top of {@param srcTgt} using the badge dimensions.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public static Bitmap badgeWithBitmap(Bitmap srcTgt, Bitmap badge, Context context) {
|
||||
int badgeSize = context.getResources().getDimensionPixelSize(R.dimen.profile_badge_size);
|
||||
synchronized (sCanvas) {
|
||||
|
|
|
@ -23,12 +23,10 @@ import android.animation.PropertyValuesHolder;
|
|||
import android.animation.RectEvaluator;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.animation.ValueAnimator.AnimatorUpdateListener;
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.util.Property;
|
||||
import android.view.View;
|
||||
import android.view.View.OnFocusChangeListener;
|
||||
|
@ -38,7 +36,6 @@ import com.android.launcher3.R;
|
|||
/**
|
||||
* A helper class to draw background of a focused view.
|
||||
*/
|
||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
||||
public abstract class FocusIndicatorHelper implements
|
||||
OnFocusChangeListener, AnimatorUpdateListener {
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.android.launcher3.InvariantDeviceProfile;
|
|||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||
import com.android.launcher3.util.ComponentKey;
|
||||
|
||||
import java.text.Collator;
|
||||
|
@ -32,10 +31,10 @@ public class WidgetItem extends ComponentKey implements Comparable<WidgetItem> {
|
|||
public final String label;
|
||||
public final int spanX, spanY;
|
||||
|
||||
public WidgetItem(LauncherAppWidgetProviderInfo info, AppWidgetManagerCompat widgetManager) {
|
||||
super(info.provider, widgetManager.getUser(info));
|
||||
public WidgetItem(LauncherAppWidgetProviderInfo info, PackageManager pm) {
|
||||
super(info.provider, info.getProfile());
|
||||
|
||||
label = Utilities.trim(widgetManager.loadLabel(info));
|
||||
label = Utilities.trim(info.getLabel(pm));
|
||||
widgetInfo = info;
|
||||
activityInfo = null;
|
||||
|
||||
|
|
|
@ -59,16 +59,16 @@ public class WidgetsModel {
|
|||
|
||||
final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
|
||||
try {
|
||||
PackageManager pm = context.getPackageManager();
|
||||
|
||||
// Widgets
|
||||
AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
|
||||
for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders()) {
|
||||
for (AppWidgetProviderInfo widgetInfo :
|
||||
AppWidgetManagerCompat.getInstance(context).getAllProviders()) {
|
||||
widgetsAndShortcuts.add(new WidgetItem(
|
||||
LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo),
|
||||
widgetManager));
|
||||
LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo), pm));
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
PackageManager pm = context.getPackageManager();
|
||||
for (ResolveInfo info :
|
||||
pm.queryIntentActivities(new Intent(Intent.ACTION_CREATE_SHORTCUT), 0)) {
|
||||
widgetsAndShortcuts.add(new WidgetItem(info, pm));
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.os.Build;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class CircleRevealOutlineProvider extends RevealOutlineAnimation {
|
||||
|
||||
private int mCenterX;
|
||||
|
|
|
@ -23,8 +23,6 @@ import android.content.IntentFilter;
|
|||
import android.content.res.Configuration;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
|
||||
/**
|
||||
* {@link BroadcastReceiver} which watches configuration changes and
|
||||
* restarts the process in case changes which affect the device profile occur.
|
||||
|
@ -40,13 +38,13 @@ public class ConfigMonitor extends BroadcastReceiver {
|
|||
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
mFontScale = config.fontScale;
|
||||
mDensity = getDensity(config);
|
||||
mDensity = config.densityDpi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Configuration config = context.getResources().getConfiguration();
|
||||
if (mFontScale != config.fontScale || mDensity != getDensity(config)) {
|
||||
if (mFontScale != config.fontScale || mDensity != config.densityDpi) {
|
||||
Log.d("ConfigMonitor", "Configuration changed, restarting launcher");
|
||||
mContext.unregisterReceiver(this);
|
||||
android.os.Process.killProcess(android.os.Process.myPid());
|
||||
|
@ -56,8 +54,4 @@ public class ConfigMonitor extends BroadcastReceiver {
|
|||
public void register() {
|
||||
mContext.registerReceiver(this, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED));
|
||||
}
|
||||
|
||||
private static int getDensity(Configuration config) {
|
||||
return Utilities.ATLEAST_JB_MR1 ? config.densityDpi : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import com.android.launcher3.LauncherModel;
|
|||
import com.android.launcher3.MainThreadExecutor;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.ShortcutInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.compat.LauncherActivityInfoCompat;
|
||||
import com.android.launcher3.compat.UserManagerCompat;
|
||||
import com.android.launcher3.shortcuts.ShortcutInfoCompat;
|
||||
|
@ -211,9 +210,6 @@ public class ManagedProfileHeuristic {
|
|||
* Verifies that entries corresponding to {@param users} exist and removes all invalid entries.
|
||||
*/
|
||||
public static void processAllUsers(List<UserHandle> users, Context context) {
|
||||
if (!Utilities.ATLEAST_LOLLIPOP) {
|
||||
return;
|
||||
}
|
||||
UserManagerCompat userManager = UserManagerCompat.getInstance(context);
|
||||
HashSet<String> validKeys = new HashSet<String>();
|
||||
for (UserHandle user : users) {
|
||||
|
|
|
@ -16,12 +16,9 @@
|
|||
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.view.ViewOutlineProvider;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
/**
|
||||
* A {@link ViewOutlineProvider} that animates a reveal in a "pill" shape.
|
||||
* A pill is simply a round rect, but we assume the width is greater than
|
||||
|
|
|
@ -16,15 +16,11 @@
|
|||
package com.android.launcher3.widget;
|
||||
|
||||
import android.appwidget.AppWidgetHostView;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.PendingAddItemInfo;
|
||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||
|
||||
/**
|
||||
* Meta data used for late binding of {@link LauncherAppWidgetProviderInfo}.
|
||||
|
@ -38,14 +34,14 @@ public class PendingAddWidgetInfo extends PendingAddItemInfo {
|
|||
public AppWidgetHostView boundWidget;
|
||||
public Bundle bindOptions = null;
|
||||
|
||||
public PendingAddWidgetInfo(Context context, LauncherAppWidgetProviderInfo i) {
|
||||
public PendingAddWidgetInfo(LauncherAppWidgetProviderInfo i) {
|
||||
if (i.isCustomWidget) {
|
||||
itemType = LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
|
||||
} else {
|
||||
itemType = LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET;
|
||||
}
|
||||
this.info = i;
|
||||
user = AppWidgetManagerCompat.getInstance(context).getUser(i);
|
||||
user = i.getUser();
|
||||
componentName = i.provider;
|
||||
previewImage = i.previewImage;
|
||||
icon = i.icon;
|
||||
|
@ -55,8 +51,4 @@ public class PendingAddWidgetInfo extends PendingAddItemInfo {
|
|||
minSpanX = i.minSpanX;
|
||||
minSpanY = i.minSpanY;
|
||||
}
|
||||
|
||||
public boolean isCustomWidget() {
|
||||
return itemType == LauncherSettings.Favorites.ITEM_TYPE_CUSTOM_APPWIDGET;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class WidgetCell extends LinearLayout implements OnLayoutChangeListener {
|
|||
if (item.activityInfo != null) {
|
||||
setTag(new PendingAddShortcutInfo(item.activityInfo));
|
||||
} else {
|
||||
setTag(new PendingAddWidgetInfo(mLauncher, item.widgetInfo));
|
||||
setTag(new PendingAddWidgetInfo(item.widgetInfo));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,12 +10,9 @@ import android.util.Log;
|
|||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.AppWidgetResizeFrame;
|
||||
import com.android.launcher3.DragSource;
|
||||
import com.android.launcher3.DropTarget;
|
||||
import com.android.launcher3.ItemInfo;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherAppWidgetProviderInfo;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.compat.AppWidgetManagerCompat;
|
||||
import com.android.launcher3.dragndrop.DragController;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
|
@ -154,27 +151,24 @@ public class WidgetHostViewLoader implements DragController.DragListener {
|
|||
}
|
||||
|
||||
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) {
|
||||
Bundle options = null;
|
||||
if (Utilities.ATLEAST_JB_MR1) {
|
||||
Rect rect = new Rect();
|
||||
AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect);
|
||||
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context,
|
||||
info.componentName, null);
|
||||
Rect rect = new Rect();
|
||||
AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect);
|
||||
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context,
|
||||
info.componentName, null);
|
||||
|
||||
float density = context.getResources().getDisplayMetrics().density;
|
||||
int xPaddingDips = (int) ((padding.left + padding.right) / density);
|
||||
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
|
||||
float density = context.getResources().getDisplayMetrics().density;
|
||||
int xPaddingDips = (int) ((padding.left + padding.right) / density);
|
||||
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
|
||||
|
||||
options = new Bundle();
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
|
||||
rect.left - xPaddingDips);
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
|
||||
rect.top - yPaddingDips);
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
|
||||
rect.right - xPaddingDips);
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
|
||||
rect.bottom - yPaddingDips);
|
||||
}
|
||||
Bundle options = new Bundle();
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
|
||||
rect.left - xPaddingDips);
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
|
||||
rect.top - yPaddingDips);
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
|
||||
rect.right - xPaddingDips);
|
||||
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
|
||||
rect.bottom - yPaddingDips);
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
*/
|
||||
package com.android.launcher3.widget;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.Adapter;
|
||||
import android.util.Log;
|
||||
|
@ -29,7 +27,6 @@ import android.widget.LinearLayout;
|
|||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.WidgetPreviewLoader;
|
||||
import com.android.launcher3.compat.AlphabeticIndexCompat;
|
||||
import com.android.launcher3.model.PackageItemInfo;
|
||||
|
@ -152,7 +149,6 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
|
|||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
@Override
|
||||
public WidgetsRowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
if (DEBUG) {
|
||||
|
@ -165,11 +161,7 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
|
|||
|
||||
// if the end padding is 0, then container view (horizontal scroll view) doesn't respect
|
||||
// the end of the linear layout width + the start padding and doesn't allow scrolling.
|
||||
if (Utilities.ATLEAST_JB_MR1) {
|
||||
cellList.setPaddingRelative(mIndent, 0, 1, 0);
|
||||
} else {
|
||||
cellList.setPadding(mIndent, 0, 1, 0);
|
||||
}
|
||||
cellList.setPaddingRelative(mIndent, 0, 1, 0);
|
||||
|
||||
return new WidgetsRowViewHolder(container);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.android.launcher3;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.appwidget.AppWidgetHost;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
|
@ -9,7 +8,6 @@ import android.content.pm.PackageInstaller;
|
|||
import android.content.pm.PackageInstaller.SessionParams;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.Cursor;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.test.uiautomator.UiSelector;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
|
@ -33,7 +31,6 @@ import java.util.concurrent.TimeUnit;
|
|||
* Note running these tests will clear the workspace on the device.
|
||||
*/
|
||||
@LargeTest
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public class BindWidgetTest extends LauncherInstrumentationTestCase {
|
||||
|
||||
private ContentResolver mResolver;
|
||||
|
@ -264,13 +261,13 @@ public class BindWidgetTest extends LauncherInstrumentationTestCase {
|
|||
item.spanY = info.minSpanY;
|
||||
item.minSpanX = info.minSpanX;
|
||||
item.minSpanY = info.minSpanY;
|
||||
item.user = mWidgetManager.getUser(info);
|
||||
item.user = info.getUser();
|
||||
item.cellX = 0;
|
||||
item.cellY = 1;
|
||||
item.container = LauncherSettings.Favorites.CONTAINER_DESKTOP;
|
||||
|
||||
if (bindWidget) {
|
||||
PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(mTargetContext, info);
|
||||
PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(info);
|
||||
pendingInfo.spanX = item.spanX;
|
||||
pendingInfo.spanY = item.spanY;
|
||||
pendingInfo.minSpanX = item.minSpanX;
|
||||
|
|
Loading…
Reference in New Issue