Merge "Various lint error fixes." into ub-launcher3-burnaby

This commit is contained in:
Sunny Goyal
2015-05-14 21:42:07 +00:00
committed by Android (Google) Code Review
43 changed files with 181 additions and 132 deletions
@@ -1247,7 +1247,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) { if (l == null || l.length <= 0) {
return null; return null;
} }
return new Long(l[0]); return Long.valueOf(l[0]);
} }
/** /**
@@ -1266,7 +1266,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) { if (l == null || l.length <= 0) {
return null; return null;
} }
return new Integer(l[0]); return Integer.valueOf(l[0]);
} }
/** /**
@@ -1285,7 +1285,7 @@ public class ExifInterface {
if (l == null || l.length <= 0) { if (l == null || l.length <= 0) {
return null; return null;
} }
return new Byte(l[0]); return Byte.valueOf(l[0]);
} }
/** /**
@@ -190,7 +190,7 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
} }
}); });
} catch (SecurityException securityException) { } catch (SecurityException securityException) {
if (isDestroyed()) { if (isActivityDestroyed()) {
// Temporarily granted permissions are revoked when the activity // Temporarily granted permissions are revoked when the activity
// finishes, potentially resulting in a SecurityException here. // finishes, potentially resulting in a SecurityException here.
// Even though {@link #isDestroyed} might also return true in different // Even though {@link #isDestroyed} might also return true in different
@@ -221,6 +221,12 @@ public class WallpaperCropActivity extends BaseActivity implements Handler.Callb
return false; return false;
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
protected boolean isActivityDestroyed() {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1)
&& isDestroyed();
}
@Thunk void addReusableBitmap(TileSource src) { @Thunk void addReusableBitmap(TileSource src) {
synchronized (mReusableBitmaps) { synchronized (mReusableBitmaps) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
@@ -665,7 +665,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
} }
@Thunk void initializeScrollForRtl() { @Thunk void initializeScrollForRtl() {
if (mWallpaperScrollContainer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { if (Utilities.isRtl(getResources())) {
final ViewTreeObserver observer = mWallpaperScrollContainer.getViewTreeObserver(); final ViewTreeObserver observer = mWallpaperScrollContainer.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
public void onGlobalLayout() { public void onGlobalLayout() {
@@ -838,7 +838,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity {
int rotation = BitmapUtils.getRotationFromExif(context, uri); int rotation = BitmapUtils.getRotationFromExif(context, uri);
return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false); return createThumbnail(defaultSize, context, uri, null, null, 0, rotation, false);
} catch (SecurityException securityException) { } catch (SecurityException securityException) {
if (isDestroyed()) { if (isActivityDestroyed()) {
// Temporarily granted permissions are revoked when the activity // Temporarily granted permissions are revoked when the activity
// finishes, potentially resulting in a SecurityException here. // finishes, potentially resulting in a SecurityException here.
// Even though {@link #isDestroyed} might also return true in different // Even though {@link #isDestroyed} might also return true in different
-1
View File
@@ -18,7 +18,6 @@
<com.android.launcher3.LauncherRootView <com.android.launcher3.LauncherRootView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res-auto" xmlns:launcher="http://schemas.android.com/apk/res-auto"
android:id="@+id/launcher" android:id="@+id/launcher"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
+1
View File
@@ -46,6 +46,7 @@
android:layout_width="@dimen/cling_migration_content_width" android:layout_width="@dimen/cling_migration_content_width"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/cling_migration_content_margin" android:layout_marginEnd="@dimen/cling_migration_content_margin"
android:layout_marginRight="@dimen/cling_migration_content_margin"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="24dp" android:paddingLeft="24dp"
android:paddingRight="24dp" > android:paddingRight="24dp" >
+1
View File
@@ -48,6 +48,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/ic_cling_migration" android:layout_below="@+id/ic_cling_migration"
android:layout_marginStart="@dimen/cling_migration_content_margin" android:layout_marginStart="@dimen/cling_migration_content_margin"
android:layout_marginLeft="@dimen/cling_migration_content_margin"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="24dp" android:paddingLeft="24dp"
android:paddingRight="24dp" > android:paddingRight="24dp" >
+2
View File
@@ -56,6 +56,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp" android:layout_marginStart="4dp"
android:paddingTop="13dp" android:paddingTop="13dp"
android:paddingBottom="13dp" android:paddingBottom="13dp"
@@ -86,6 +87,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end|center_vertical" android:layout_gravity="end|center_vertical"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:layout_marginRight="6dp"
android:paddingTop="13dp" android:paddingTop="13dp"
android:paddingBottom="13dp" android:paddingBottom="13dp"
android:contentDescription="@string/apps_view_search_bar_hint" android:contentDescription="@string/apps_view_search_bar_hint"
+3
View File
@@ -36,6 +36,7 @@
<com.android.launcher3.DeleteDropTarget <com.android.launcher3.DeleteDropTarget
android:id="@+id/delete_target_text" android:id="@+id/delete_target_text"
style="@style/DropTargetButton" style="@style/DropTargetButton"
android:drawableLeft="@drawable/remove_target_selector"
android:drawableStart="@drawable/remove_target_selector" android:drawableStart="@drawable/remove_target_selector"
android:text="@string/delete_target_label" /> android:text="@string/delete_target_label" />
</FrameLayout> </FrameLayout>
@@ -49,6 +50,7 @@
<com.android.launcher3.InfoDropTarget <com.android.launcher3.InfoDropTarget
android:id="@+id/info_target_text" android:id="@+id/info_target_text"
style="@style/DropTargetButton" style="@style/DropTargetButton"
android:drawableLeft="@drawable/info_target_selector"
android:drawableStart="@drawable/info_target_selector" android:drawableStart="@drawable/info_target_selector"
android:text="@string/info_target_label" /> android:text="@string/info_target_label" />
</FrameLayout> </FrameLayout>
@@ -62,6 +64,7 @@
<com.android.launcher3.UninstallDropTarget <com.android.launcher3.UninstallDropTarget
android:id="@+id/uninstall_target_text" android:id="@+id/uninstall_target_text"
style="@style/DropTargetButton" style="@style/DropTargetButton"
android:drawableLeft="@drawable/uninstall_target_selector"
android:drawableStart="@drawable/uninstall_target_selector" android:drawableStart="@drawable/uninstall_target_selector"
android:text="@string/delete_target_uninstall_label" /> android:text="@string/delete_target_uninstall_label" />
</FrameLayout> </FrameLayout>
+1
View File
@@ -58,6 +58,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/widget_row_padding" android:layout_marginStart="@dimen/widget_row_padding"
android:layout_marginLeft="@dimen/widget_row_padding"
android:orientation="horizontal" android:orientation="horizontal"
android:divider="@drawable/widgets_row_divider" android:divider="@drawable/widgets_row_divider"
android:showDividers="middle" android:showDividers="middle"
+1 -1
View File
@@ -28,7 +28,7 @@
</style> </style>
<!-- This style applies to the drop target when it is shown in the sidebar --> <!-- This style applies to the drop target when it is shown in the sidebar -->
<style name="DropTargetButton" parent="DropTargetButton.Base"> <style name="DropTargetButton" parent="DropTargetButtonBase">
<item name="android:layout_height">wrap_content</item> <item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center</item> <item name="android:gravity">center</item>
<item name="android:drawablePadding">0dp</item> <item name="android:drawablePadding">0dp</item>
+1 -1
View File
@@ -27,7 +27,7 @@
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">match_parent</item>
</style> </style>
<style name="DropTargetButton" parent="DropTargetButton.Base"> <style name="DropTargetButton" parent="DropTargetButtonBase">
<item name="android:paddingLeft">60dp</item> <item name="android:paddingLeft">60dp</item>
<item name="android:paddingRight">60dp</item> <item name="android:paddingRight">60dp</item>
<item name="android:shadowColor">#393939</item> <item name="android:shadowColor">#393939</item>
+2 -2
View File
@@ -54,7 +54,7 @@
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">match_parent</item>
</style> </style>
<style name="DropTargetButton.Base"> <style name="DropTargetButtonBase">
<item name="android:layout_width">wrap_content</item> <item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">match_parent</item> <item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">center</item> <item name="android:layout_gravity">center</item>
@@ -72,7 +72,7 @@
<item name="android:shadowRadius">4.0</item> <item name="android:shadowRadius">4.0</item>
</style> </style>
<style name="DropTargetButton" parent="DropTargetButton.Base"></style> <style name="DropTargetButton" parent="DropTargetButtonBase" />
<style name="PreloadIcon"> <style name="PreloadIcon">
<item name="background">@drawable/virtual_preload</item> <item name="background">@drawable/virtual_preload</item>
@@ -292,8 +292,7 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView {
if (mFastScrollAlpha > 0f && !mFastScrollSectionName.isEmpty()) { if (mFastScrollAlpha > 0f && !mFastScrollSectionName.isEmpty()) {
int x; int x;
int y; int y;
boolean isRtl = (getResources().getConfiguration().getLayoutDirection() == boolean isRtl = Utilities.isRtl(getResources());
LAYOUT_DIRECTION_RTL);
// Calculate the position for the fast scroller popup // Calculate the position for the fast scroller popup
Rect bgBounds = mFastScrollerBg.getBounds(); Rect bgBounds = mFastScrollerBg.getBounds();
@@ -411,8 +410,7 @@ public class AppsContainerRecyclerView extends BaseContainerRecyclerView {
// Find the index and height of the first visible row (all rows have the same height) // Find the index and height of the first visible row (all rows have the same height)
int x; int x;
int y; int y;
boolean isRtl = (getResources().getConfiguration().getLayoutDirection() == boolean isRtl = Utilities.isRtl(getResources());
LAYOUT_DIRECTION_RTL);
int rowCount = getNumRows(); int rowCount = getNumRows();
getCurScrollState(mScrollPosState, items); getCurScrollState(mScrollPosState, items);
if (mScrollPosState.rowIndex != -1) { if (mScrollPosState.rowIndex != -1) {
@@ -15,12 +15,15 @@
*/ */
package com.android.launcher3; package com.android.launcher3;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
@@ -198,8 +201,7 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
@Override @Override
protected void onFinishInflate() { protected void onFinishInflate() {
boolean isRtl = (getResources().getConfiguration().getLayoutDirection() == boolean isRtl = Utilities.isRtl(getResources());
LAYOUT_DIRECTION_RTL);
mAdapter.setRtl(isRtl); mAdapter.setRtl(isRtl);
// Work around the search box getting first focus and showing the cursor by // Work around the search box getting first focus and showing the cursor by
@@ -329,8 +331,7 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
*/ */
@Override @Override
protected void onUpdatePaddings() { protected void onUpdatePaddings() {
boolean isRtl = (getResources().getConfiguration().getLayoutDirection() == boolean isRtl = Utilities.isRtl(getResources());
LAYOUT_DIRECTION_RTL);
boolean hasSearchBar = (mSearchBarEditView != null) && boolean hasSearchBar = (mSearchBarEditView != null) &&
(mSearchBarEditView.getVisibility() == View.VISIBLE); (mSearchBarEditView.getVisibility() == View.VISIBLE);
@@ -396,11 +397,13 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
return handleTouchEvent(ev); return handleTouchEvent(ev);
} }
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
return handleTouchEvent(ev); return handleTouchEvent(ev);
} }
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent ev) { public boolean onTouch(View v, MotionEvent ev) {
switch (ev.getAction()) { switch (ev.getAction()) {
@@ -614,6 +617,7 @@ public class AppsContainerView extends BaseContainerView implements DragSource,
/** /**
* Updates the container when the recycler view is scrolled. * Updates the container when the recycler view is scrolled.
*/ */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onRecyclerViewScrolled() { private void onRecyclerViewScrolled() {
if (DYNAMIC_HEADER_ELEVATION && Utilities.isLmpOrAbove()) { if (DYNAMIC_HEADER_ELEVATION && Utilities.isLmpOrAbove()) {
int elevation = DynamicGrid.pxFromDp(HEADER_ELEVATION_DP, int elevation = DynamicGrid.pxFromDp(HEADER_ELEVATION_DP,
@@ -16,6 +16,7 @@
package com.android.launcher3; package com.android.launcher3;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
@@ -25,6 +26,7 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Region; import android.graphics.Region;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.SparseArray; import android.util.SparseArray;
import android.util.TypedValue; import android.util.TypedValue;
@@ -444,15 +446,20 @@ public class BubbleTextView extends TextView {
/** /**
* Sets the icon for this view based on the layout direction. * Sets the icon for this view based on the layout direction.
*/ */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private Drawable setIcon(Drawable icon, int iconSize) { private Drawable setIcon(Drawable icon, int iconSize) {
mIcon = icon; mIcon = icon;
if (iconSize != -1) { if (iconSize != -1) {
mIcon.setBounds(0, 0, iconSize, iconSize); mIcon.setBounds(0, 0, iconSize, iconSize);
} }
if (mLayoutHorizontal) { if (mLayoutHorizontal) {
setCompoundDrawablesRelative(mIcon, null, null, null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
setCompoundDrawablesRelative(mIcon, null, null, null);
} else {
setCompoundDrawables(mIcon, null, null, null);
}
} else { } else {
setCompoundDrawablesRelative(null, mIcon, null, null); setCompoundDrawables(null, mIcon, null, null);
} }
return icon; return icon;
} }
@@ -83,6 +83,7 @@ public abstract class ButtonDropTarget extends TextView
} }
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
protected void setDrawable(int resId) { protected void setDrawable(int resId) {
// Get the hover color // Get the hover color
mDrawable = (TransitionDrawable) getCurrentDrawable(); mDrawable = (TransitionDrawable) getCurrentDrawable();
@@ -90,7 +91,11 @@ public abstract class ButtonDropTarget extends TextView
if (mDrawable == null) { if (mDrawable == null) {
// TODO: investigate why this is ever happening. Presently only on one known device. // TODO: investigate why this is ever happening. Presently only on one known device.
mDrawable = (TransitionDrawable) getResources().getDrawable(resId); mDrawable = (TransitionDrawable) getResources().getDrawable(resId);
setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
} else {
setCompoundDrawablesWithIntrinsicBounds(mDrawable, null, null, null);
}
} }
if (null != mDrawable) { if (null != mDrawable) {
@@ -107,7 +112,7 @@ public abstract class ButtonDropTarget extends TextView
} }
protected Drawable getCurrentDrawable() { protected Drawable getCurrentDrawable() {
Drawable[] drawables = getCompoundDrawablesRelative(); Drawable[] drawables = getCompoundDrawables();
for (int i = 0; i < drawables.length; ++i) { for (int i = 0; i < drawables.length; ++i) {
if (drawables[i] != null) { if (drawables[i] != null) {
return drawables[i]; return drawables[i];
@@ -241,10 +246,6 @@ public abstract class ButtonDropTarget extends TextView
outRect.offsetTo(coords[0], coords[1]); outRect.offsetTo(coords[0], coords[1]);
} }
private boolean isRtl() {
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
}
protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) { protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) {
DragLayer dragLayer = mLauncher.getDragLayer(); DragLayer dragLayer = mLauncher.getDragLayer();
@@ -258,7 +259,7 @@ public abstract class ButtonDropTarget extends TextView
final int left; final int left;
final int right; final int right;
if (isRtl()) { if (Utilities.isRtl(getResources())) {
right = to.right - getPaddingRight(); right = to.right - getPaddingRight();
left = right - width; left = right - width;
} else { } else {
+1 -5
View File
@@ -459,11 +459,7 @@ public class DeviceProfile {
isLandscape = (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE); isLandscape = (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE);
isTablet = resources.getBoolean(R.bool.is_tablet); isTablet = resources.getBoolean(R.bool.is_tablet);
isLargeTablet = resources.getBoolean(R.bool.is_large_tablet); isLargeTablet = resources.getBoolean(R.bool.is_large_tablet);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { isLayoutRtl = Utilities.isRtl(resources);
isLayoutRtl = (configuration.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
} else {
isLayoutRtl = false;
}
widthPx = wPx; widthPx = wPx;
heightPx = hPx; heightPx = hPx;
availableWidthPx = awPx; availableWidthPx = awPx;
@@ -71,6 +71,7 @@ public class DragController {
// temporaries to avoid gc thrash // temporaries to avoid gc thrash
private Rect mRectTemp = new Rect(); private Rect mRectTemp = new Rect();
private final int[] mCoordinatesTemp = new int[2]; private final int[] mCoordinatesTemp = new int[2];
private final boolean mIsRtl;
/** Whether or not we're dragging. */ /** Whether or not we're dragging. */
private boolean mDragging; private boolean mDragging;
@@ -157,6 +158,7 @@ public class DragController {
float density = r.getDisplayMetrics().density; float density = r.getDisplayMetrics().density;
mFlingToDeleteThresholdVelocity = mFlingToDeleteThresholdVelocity =
(int) (r.getInteger(R.integer.config_flingToDeleteMinVelocity) * density); (int) (r.getInteger(R.integer.config_flingToDeleteMinVelocity) * density);
mIsRtl = Utilities.isRtl(r);
} }
public boolean dragging() { public boolean dragging() {
@@ -548,9 +550,8 @@ public class DragController {
final int slop = ViewConfiguration.get(mLauncher).getScaledWindowTouchSlop(); final int slop = ViewConfiguration.get(mLauncher).getScaledWindowTouchSlop();
final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY; final int delay = mDistanceSinceScroll < slop ? RESCROLL_DELAY : SCROLL_DELAY;
final DragLayer dragLayer = mLauncher.getDragLayer(); final DragLayer dragLayer = mLauncher.getDragLayer();
final boolean isRtl = (dragLayer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL); final int forwardDirection = mIsRtl ? SCROLL_RIGHT : SCROLL_LEFT;
final int forwardDirection = isRtl ? SCROLL_RIGHT : SCROLL_LEFT; final int backwardsDirection = mIsRtl ? SCROLL_LEFT : SCROLL_RIGHT;
final int backwardsDirection = isRtl ? SCROLL_LEFT : SCROLL_RIGHT;
if (x < mScrollZone) { if (x < mScrollZone) {
if (mScrollState == SCROLL_OUTSIDE_ZONE) { if (mScrollState == SCROLL_OUTSIDE_ZONE) {
+4 -10
View File
@@ -60,6 +60,7 @@ public class DragLayer extends InsettableFrameLayout {
// Variables relating to resizing widgets // Variables relating to resizing widgets
private final ArrayList<AppWidgetResizeFrame> mResizeFrames = private final ArrayList<AppWidgetResizeFrame> mResizeFrames =
new ArrayList<AppWidgetResizeFrame>(); new ArrayList<AppWidgetResizeFrame>();
private final boolean mIsRtl;
private AppWidgetResizeFrame mCurrentResizeFrame; private AppWidgetResizeFrame mCurrentResizeFrame;
// Variables relating to animation of views after drop // Variables relating to animation of views after drop
@@ -113,6 +114,7 @@ public class DragLayer extends InsettableFrameLayout {
mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right); mRightHoverDrawable = res.getDrawable(R.drawable.page_hover_right);
mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active); mLeftHoverDrawableActive = res.getDrawable(R.drawable.page_hover_left_active);
mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active); mRightHoverDrawableActive = res.getDrawable(R.drawable.page_hover_right_active);
mIsRtl = Utilities.isRtl(res);
} }
public void setup(Launcher launcher, DragController controller) { public void setup(Launcher launcher, DragController controller) {
@@ -920,13 +922,6 @@ public class DragLayer extends InsettableFrameLayout {
invalidate(); invalidate();
} }
/**
* Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api.
*/
private boolean isLayoutRtl() {
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
}
@Override @Override
protected void dispatchDraw(Canvas canvas) { protected void dispatchDraw(Canvas canvas) {
// Draw the background below children. // Draw the background below children.
@@ -947,9 +942,8 @@ public class DragLayer extends InsettableFrameLayout {
childRect); childRect);
int page = workspace.getNextPage(); int page = workspace.getNextPage();
final boolean isRtl = isLayoutRtl(); CellLayout leftPage = (CellLayout) workspace.getChildAt(mIsRtl ? page + 1 : page - 1);
CellLayout leftPage = (CellLayout) workspace.getChildAt(isRtl ? page + 1 : page - 1); CellLayout rightPage = (CellLayout) workspace.getChildAt(mIsRtl ? page - 1 : page + 1);
CellLayout rightPage = (CellLayout) workspace.getChildAt(isRtl ? page - 1 : page + 1);
if (leftPage != null && leftPage.isDragTarget()) { if (leftPage != null && leftPage.isDragTarget()) {
Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ? Drawable left = mInScrollArea && leftPage.getIsDragOverlapping() ?
+1
View File
@@ -76,6 +76,7 @@ public class DragView extends View {
* @param registrationX The x coordinate of the registration point. * @param registrationX The x coordinate of the registration point.
* @param registrationY The y 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, public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY,
int left, int top, int width, int height, final float initialScale) { int left, int top, int width, int height, final float initialScale) {
super(launcher); super(launcher);
+7 -6
View File
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
@@ -48,7 +49,6 @@ import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.CellLayout.CellInfo; import com.android.launcher3.CellLayout.CellInfo;
import com.android.launcher3.DragController.DragListener; import com.android.launcher3.DragController.DragListener;
import com.android.launcher3.FolderInfo.FolderListener; import com.android.launcher3.FolderInfo.FolderListener;
@@ -56,7 +56,6 @@ import com.android.launcher3.LauncherAccessibilityDelegate.AccessibilityDragSour
import com.android.launcher3.UninstallDropTarget.UninstallSource; import com.android.launcher3.UninstallDropTarget.UninstallSource;
import com.android.launcher3.Workspace.ItemOperator; import com.android.launcher3.Workspace.ItemOperator;
import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -330,6 +329,7 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
/** /**
* We need to handle touch events to prevent them from falling through to the workspace below. * We need to handle touch events to prevent them from falling through to the workspace below.
*/ */
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
return true; return true;
@@ -406,8 +406,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
* *
* @return A new UserFolder. * @return A new UserFolder.
*/ */
static Folder fromXml(Context context) { static Folder fromXml(Launcher launcher) {
return (Folder) LayoutInflater.from(context).inflate(R.layout.user_folder, null); return (Folder) LayoutInflater.from(launcher).inflate(R.layout.user_folder,
launcher.getDragLayer(), false);
} }
/** /**
@@ -698,10 +699,10 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList
boolean isOutsideLeftEdge = x < cellOverlap; boolean isOutsideLeftEdge = x < cellOverlap;
boolean isOutsideRightEdge = x > (getWidth() - cellOverlap); boolean isOutsideRightEdge = x > (getWidth() - cellOverlap);
if (currentPage > 0 && (mContent.rtlLayout ? isOutsideRightEdge : isOutsideLeftEdge)) { if (currentPage > 0 && (mContent.mIsRtl ? isOutsideRightEdge : isOutsideLeftEdge)) {
showScrollHint(DragController.SCROLL_LEFT, d); showScrollHint(DragController.SCROLL_LEFT, d);
} else if (currentPage < (mContent.getPageCount() - 1) } else if (currentPage < (mContent.getPageCount() - 1)
&& (mContent.rtlLayout ? isOutsideLeftEdge : isOutsideRightEdge)) { && (mContent.mIsRtl ? isOutsideLeftEdge : isOutsideRightEdge)) {
showScrollHint(DragController.SCROLL_RIGHT, d); showScrollHint(DragController.SCROLL_RIGHT, d);
} else { } else {
mOnScrollHintAlarm.cancelAlarm(); mOnScrollHintAlarm.cancelAlarm();
@@ -55,7 +55,7 @@ public class FolderPagedView extends PagedView {
private static final int[] sTempPosArray = new int[2]; private static final int[] sTempPosArray = new int[2];
public final boolean rtlLayout; public final boolean mIsRtl;
private final LayoutInflater mInflater; private final LayoutInflater mInflater;
private final IconCache mIconCache; private final IconCache mIconCache;
@@ -89,7 +89,7 @@ public class FolderPagedView extends PagedView {
mInflater = LayoutInflater.from(context); mInflater = LayoutInflater.from(context);
mIconCache = app.getIconCache(); mIconCache = app.getIconCache();
rtlLayout = getResources().getConfiguration().getLayoutDirection() == LAYOUT_DIRECTION_RTL; mIsRtl = Utilities.isRtl(getResources());
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
} }
@@ -439,7 +439,7 @@ public class FolderPagedView extends PagedView {
* Scrolls the current view by a fraction * Scrolls the current view by a fraction
*/ */
public void showScrollHint(int direction) { public void showScrollHint(int direction) {
float fraction = (direction == DragController.SCROLL_LEFT) ^ rtlLayout float fraction = (direction == DragController.SCROLL_LEFT) ^ mIsRtl
? -SCROLL_HINT_FRACTION : SCROLL_HINT_FRACTION; ? -SCROLL_HINT_FRACTION : SCROLL_HINT_FRACTION;
int hint = (int) (fraction * getWidth()); int hint = (int) (fraction * getWidth());
int scroll = getScrollForPage(getNextPage()) + hint; int scroll = getScrollForPage(getNextPage()) + hint;
@@ -596,7 +596,7 @@ public class FolderPagedView extends PagedView {
} }
}; };
v.animate() v.animate()
.translationXBy((direction > 0 ^ rtlLayout) ? -v.getWidth() : v.getWidth()) .translationXBy((direction > 0 ^ mIsRtl) ? -v.getWidth() : v.getWidth())
.setDuration(REORDER_ANIMATION_DURATION) .setDuration(REORDER_ANIMATION_DURATION)
.setStartDelay(0) .setStartDelay(0)
.withEndAction(endAction); .withEndAction(endAction);
+13 -3
View File
@@ -16,8 +16,10 @@
package com.android.launcher3; package com.android.launcher3;
import android.annotation.TargetApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.provider.Settings; import android.provider.Settings;
import android.util.AttributeSet; import android.util.AttributeSet;
@@ -68,10 +70,18 @@ public class InfoDropTarget extends ButtonDropTarget {
return source.supportsAppInfoDropTarget() && supportsDrop(getContext(), info); return source.supportsAppInfoDropTarget() && supportsDrop(getContext(), info);
} }
@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean supportsDrop(Context context, Object info) { public static boolean supportsDrop(Context context, Object info) {
return (Settings.Global.getInt(context.getContentResolver(), if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) && return (Settings.Global.getInt(context.getContentResolver(),
(info instanceof AppInfo || info instanceof PendingAddItemInfo); Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) &&
(info instanceof AppInfo || info instanceof PendingAddItemInfo);
} else {
return (Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.DEVELOPMENT_SETTINGS_ENABLED, 0) == 1) &&
(info instanceof AppInfo || info instanceof PendingAddItemInfo);
}
} }
@Override @Override
+3 -1
View File
@@ -22,6 +22,7 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.ActivityManager; import android.app.ActivityManager;
@@ -64,7 +65,6 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.StrictMode; import android.os.StrictMode;
import android.os.SystemClock; import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.text.Selection; import android.text.Selection;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
@@ -2582,6 +2582,7 @@ public class Launcher extends Activity
} }
} }
@SuppressLint("ClickableViewAccessibility")
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return false; return false;
} }
@@ -2850,6 +2851,7 @@ public class Launcher extends Activity
public View.OnTouchListener getHapticFeedbackTouchListener() { public View.OnTouchListener getHapticFeedbackTouchListener() {
if (mHapticFeedbackTouchListener == null) { if (mHapticFeedbackTouchListener == null) {
mHapticFeedbackTouchListener = new View.OnTouchListener() { mHapticFeedbackTouchListener = new View.OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) { if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_DOWN) {
@@ -21,10 +21,11 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.os.Build;
import android.view.View; import android.view.View;
import android.view.ViewAnimationUtils; import android.view.ViewAnimationUtils;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import java.util.HashSet; import java.util.HashSet;
import java.util.WeakHashMap; import java.util.WeakHashMap;
@@ -128,6 +129,7 @@ public class LauncherAnimUtils {
return anim; return anim;
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator createCircularReveal(View view, int centerX, public static Animator createCircularReveal(View view, int centerX,
int centerY, float startRadius, float endRadius) { int centerY, float startRadius, float endRadius) {
Animator anim = ViewAnimationUtils.createCircularReveal(view, centerX, Animator anim = ViewAnimationUtils.createCircularReveal(view, centerX,
@@ -1,10 +1,12 @@
package com.android.launcher3; package com.android.launcher3;
import android.annotation.TargetApi;
import android.appwidget.AppWidgetProviderInfo; import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Parcel; import android.os.Parcel;
/** /**
@@ -32,6 +34,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
info.writeToParcel(p, 0); info.writeToParcel(p, 0);
p.setDataPosition(0); p.setDataPosition(0);
LauncherAppWidgetProviderInfo lawpi = new LauncherAppWidgetProviderInfo(p); LauncherAppWidgetProviderInfo lawpi = new LauncherAppWidgetProviderInfo(p);
p.recycle();
int[] minResizeSpan = Launcher.getMinSpanForWidget(context, lawpi); int[] minResizeSpan = Launcher.getMinSpanForWidget(context, lawpi);
int[] span = Launcher.getSpanForWidget(context, lawpi); int[] span = Launcher.getSpanForWidget(context, lawpi);
@@ -64,6 +67,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
minSpanY = widget.getMinSpanY(); minSpanY = widget.getMinSpanY();
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public String getLabel(PackageManager packageManager) { public String getLabel(PackageManager packageManager) {
if (isCustomWidget) { if (isCustomWidget) {
return Utilities.trim(label); return Utilities.trim(label);
@@ -71,6 +75,7 @@ public class LauncherAppWidgetProviderInfo extends AppWidgetProviderInfo {
return super.loadLabel(packageManager); return super.loadLabel(packageManager);
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Drawable getIcon(Context context, IconCache cache) { public Drawable getIcon(Context context, IconCache cache) {
if (isCustomWidget) { if (isCustomWidget) {
return cache.getFullResIcon(provider.getPackageName(), icon); return cache.getFullResIcon(provider.getPackageName(), icon);
@@ -20,10 +20,12 @@ import android.accounts.Account;
import android.accounts.AccountManager; import android.accounts.AccountManager;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.annotation.TargetApi;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserManager; import android.os.UserManager;
import android.provider.Settings; import android.provider.Settings;
@@ -34,7 +36,6 @@ import android.view.View.OnLongClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnGlobalLayoutListener; import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.view.accessibility.AccessibilityManager; import android.view.accessibility.AccessibilityManager;
import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk;
class LauncherClings implements OnClickListener { class LauncherClings implements OnClickListener {
@@ -212,6 +213,7 @@ class LauncherClings implements OnClickListener {
} }
/** Returns whether the clings are enabled or should be shown */ /** Returns whether the clings are enabled or should be shown */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
private boolean areClingsEnabled() { private boolean areClingsEnabled() {
if (DISABLE_CLINGS) { if (DISABLE_CLINGS) {
return false; return false;
@@ -22,16 +22,17 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.animation.TimeInterpolator; import android.animation.TimeInterpolator;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewAnimationUtils; import android.view.ViewAnimationUtils;
import android.view.animation.AccelerateInterpolator; import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk;
import com.android.launcher3.widget.WidgetsContainerView; import com.android.launcher3.widget.WidgetsContainerView;
import java.util.HashMap; import java.util.HashMap;
/** /**
@@ -227,6 +228,7 @@ public class LauncherStateTransitionAnimation {
/** /**
* Creates and starts a new animation to a particular overlay view. * Creates and starts a new animation to a particular overlay view.
*/ */
@SuppressLint("NewApi")
private void startAnimationToOverlay(final Workspace.State toWorkspaceState, final View toView, private void startAnimationToOverlay(final Workspace.State toWorkspaceState, final View toView,
final View contentView, final View revealView, final boolean animated, final View contentView, final View revealView, final boolean animated,
final boolean hideSearchBar, final PrivateTransitionCallbacks pCb) { final boolean hideSearchBar, final PrivateTransitionCallbacks pCb) {
+1 -1
View File
@@ -101,7 +101,7 @@ public class MemoryTracker extends Service {
public void startTrackingProcess(int pid, String name, long start) { public void startTrackingProcess(int pid, String name, long start) {
synchronized (mLock) { synchronized (mLock) {
final Long lpid = new Long(pid); final Long lpid = Long.valueOf(pid);
if (mPids.contains(lpid)) return; if (mPids.contains(lpid)) return;
+18 -27
View File
@@ -221,6 +221,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private static final Rect sTmpRect = new Rect(); private static final Rect sTmpRect = new Rect();
protected final Rect mInsets = new Rect(); protected final Rect mInsets = new Rect();
protected final boolean mIsRtl;
public interface PageSwitchListener { public interface PageSwitchListener {
void onPageSwitch(View newPage, int newPageIndex); void onPageSwitch(View newPage, int newPageIndex);
@@ -248,6 +249,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
a.recycle(); a.recycle();
setHapticFeedbackEnabled(false); setHapticFeedbackEnabled(false);
mIsRtl = Utilities.isRtl(getResources());
init(); init();
} }
@@ -402,13 +404,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
} }
} }
/**
* Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api.
*/
public boolean isLayoutRtl() {
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
}
/** /**
* Returns the index of the currently displayed page. * Returns the index of the currently displayed page.
*/ */
@@ -586,16 +581,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
x = Math.max(x, mFreeScrollMinScrollX); x = Math.max(x, mFreeScrollMinScrollX);
} }
final boolean isRtl = isLayoutRtl();
mUnboundedScrollX = x; mUnboundedScrollX = x;
boolean isXBeforeFirstPage = isRtl ? (x > mMaxScrollX) : (x < 0); boolean isXBeforeFirstPage = mIsRtl ? (x > mMaxScrollX) : (x < 0);
boolean isXAfterLastPage = isRtl ? (x < 0) : (x > mMaxScrollX); boolean isXAfterLastPage = mIsRtl ? (x < 0) : (x > mMaxScrollX);
if (isXBeforeFirstPage) { if (isXBeforeFirstPage) {
super.scrollTo(0, y); super.scrollTo(0, y);
if (mAllowOverScroll) { if (mAllowOverScroll) {
mWasInOverscroll = true; mWasInOverscroll = true;
if (isRtl) { if (mIsRtl) {
overScroll(x - mMaxScrollX); overScroll(x - mMaxScrollX);
} else { } else {
overScroll(x); overScroll(x);
@@ -605,7 +599,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
super.scrollTo(mMaxScrollX, y); super.scrollTo(mMaxScrollX, y);
if (mAllowOverScroll) { if (mAllowOverScroll) {
mWasInOverscroll = true; mWasInOverscroll = true;
if (isRtl) { if (mIsRtl) {
overScroll(x); overScroll(x);
} else { } else {
overScroll(x - mMaxScrollX); overScroll(x - mMaxScrollX);
@@ -844,11 +838,9 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// Update the viewport offsets // Update the viewport offsets
mViewport.offset(offsetX, offsetY); mViewport.offset(offsetX, offsetY);
final boolean isRtl = isLayoutRtl(); final int startIndex = mIsRtl ? childCount - 1 : 0;
final int endIndex = mIsRtl ? -1 : childCount;
final int startIndex = isRtl ? childCount - 1 : 0; final int delta = mIsRtl ? -1 : 1;
final int endIndex = isRtl ? -1 : childCount;
final int delta = isRtl ? -1 : 1;
int verticalPadding = getPaddingTop() + getPaddingBottom(); int verticalPadding = getPaddingTop() + getPaddingBottom();
@@ -951,7 +943,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
private void updateMaxScrollX() { private void updateMaxScrollX() {
int childCount = getChildCount(); int childCount = getChildCount();
if (childCount > 0) { if (childCount > 0) {
final int index = isLayoutRtl() ? 0 : childCount - 1; final int index = mIsRtl ? 0 : childCount - 1;
mMaxScrollX = getScrollForPage(index); mMaxScrollX = getScrollForPage(index);
} else { } else {
mMaxScrollX = 0; mMaxScrollX = 0;
@@ -1261,7 +1253,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
* Return true if a tap at (x, y) should trigger a flip to the previous page. * Return true if a tap at (x, y) should trigger a flip to the previous page.
*/ */
protected boolean hitsPreviousPage(float x, float y) { protected boolean hitsPreviousPage(float x, float y) {
if (isLayoutRtl()) { if (mIsRtl) {
return (x > (getViewportOffsetX() + getViewportWidth() - return (x > (getViewportOffsetX() + getViewportWidth() -
getPaddingRight() - mPageSpacing)); getPaddingRight() - mPageSpacing));
} }
@@ -1272,7 +1264,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
* Return true if a tap at (x, y) should trigger a flip to the next page. * Return true if a tap at (x, y) should trigger a flip to the next page.
*/ */
protected boolean hitsNextPage(float x, float y) { protected boolean hitsNextPage(float x, float y) {
if (isLayoutRtl()) { if (mIsRtl) {
return (x < getViewportOffsetX() + getPaddingLeft() + mPageSpacing); return (x < getViewportOffsetX() + getPaddingLeft() + mPageSpacing);
} }
return (x > (getViewportOffsetX() + getViewportWidth() - return (x > (getViewportOffsetX() + getViewportWidth() -
@@ -1462,7 +1454,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
final int totalDistance; final int totalDistance;
int adjacentPage = page + 1; int adjacentPage = page + 1;
if ((delta < 0 && !isLayoutRtl()) || (delta > 0 && isLayoutRtl())) { if ((delta < 0 && !mIsRtl) || (delta > 0 && mIsRtl)) {
adjacentPage = page - 1; adjacentPage = page - 1;
} }
@@ -1497,7 +1489,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
int scrollOffset = 0; int scrollOffset = 0;
LayoutParams lp = (LayoutParams) child.getLayoutParams(); LayoutParams lp = (LayoutParams) child.getLayoutParams();
if (!lp.isFullScreenPage) { if (!lp.isFullScreenPage) {
scrollOffset = isLayoutRtl() ? getPaddingRight() : getPaddingLeft(); scrollOffset = mIsRtl ? getPaddingRight() : getPaddingLeft();
} }
int baselineX = mPageScrolls[index] + scrollOffset + getViewportOffsetX(); int baselineX = mPageScrolls[index] + scrollOffset + getViewportOffsetX();
@@ -1574,7 +1566,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
void updateFreescrollBounds() { void updateFreescrollBounds() {
getFreeScrollPageRange(mTempVisiblePagesRange); getFreeScrollPageRange(mTempVisiblePagesRange);
if (isLayoutRtl()) { if (mIsRtl) {
mFreeScrollMinScrollX = getScrollForPage(mTempVisiblePagesRange[1]); mFreeScrollMinScrollX = getScrollForPage(mTempVisiblePagesRange[1]);
mFreeScrollMaxScrollX = getScrollForPage(mTempVisiblePagesRange[0]); mFreeScrollMaxScrollX = getScrollForPage(mTempVisiblePagesRange[0]);
} else { } else {
@@ -1813,9 +1805,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
// We give flings precedence over large moves, which is why we short-circuit our // We give flings precedence over large moves, which is why we short-circuit our
// test for a large move if a fling has been registered. That is, a large // test for a large move if a fling has been registered. That is, a large
// move to the left and fling to the right will register as a fling to the right. // move to the left and fling to the right will register as a fling to the right.
final boolean isRtl = isLayoutRtl(); boolean isDeltaXLeft = mIsRtl ? deltaX > 0 : deltaX < 0;
boolean isDeltaXLeft = isRtl ? deltaX > 0 : deltaX < 0; boolean isVelocityXLeft = mIsRtl ? velocityX > 0 : velocityX < 0;
boolean isVelocityXLeft = isRtl ? velocityX > 0 : velocityX < 0;
if (((isSignificantMove && !isDeltaXLeft && !isFling) || if (((isSignificantMove && !isDeltaXLeft && !isFling) ||
(isFling && !isVelocityXLeft)) && mCurrentPage > 0) { (isFling && !isVelocityXLeft)) && mCurrentPage > 0) {
finalPage = returnToOriginalPage ? mCurrentPage : mCurrentPage - 1; finalPage = returnToOriginalPage ? mCurrentPage : mCurrentPage - 1;
@@ -1939,7 +1930,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL); hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
} }
if (hscroll != 0 || vscroll != 0) { if (hscroll != 0 || vscroll != 0) {
boolean isForwardScroll = isLayoutRtl() ? (hscroll < 0 || vscroll < 0) boolean isForwardScroll = mIsRtl ? (hscroll < 0 || vscroll < 0)
: (hscroll > 0 || vscroll > 0); : (hscroll > 0 || vscroll > 0);
if (isForwardScroll) { if (isForwardScroll) {
scrollRight(); scrollRight();
@@ -170,11 +170,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup {
} }
public boolean invertLayoutHorizontally() { public boolean invertLayoutHorizontally() {
return mInvertIfRtl && isLayoutRtl(); return mInvertIfRtl && Utilities.isRtl(getResources());
}
public boolean isLayoutRtl() {
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL);
} }
@Override @Override
@@ -1,5 +1,6 @@
package com.android.launcher3; package com.android.launcher3;
import android.annotation.TargetApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
@@ -7,7 +8,6 @@ import android.os.Bundle;
import android.os.UserManager; import android.os.UserManager;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Pair; import android.util.Pair;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.compat.UserHandleCompat;
import com.android.launcher3.util.Thunk; import com.android.launcher3.util.Thunk;
@@ -36,6 +36,7 @@ public class UninstallDropTarget extends ButtonDropTarget {
return supportsDrop(getContext(), info); return supportsDrop(getContext(), info);
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public static boolean supportsDrop(Context context, Object info) { public static boolean supportsDrop(Context context, Object info) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE); UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
+6
View File
@@ -631,4 +631,10 @@ public final class Utilities {
Matcher m = sTrimPattern.matcher(s); Matcher m = sTrimPattern.matcher(s);
return m.replaceAll("$1"); return m.replaceAll("$1");
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static boolean isRtl(Resources res) {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) &&
(res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL);
}
} }
+19 -19
View File
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.LayoutTransition; import android.animation.LayoutTransition;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder; import android.animation.PropertyValuesHolder;
import android.annotation.SuppressLint;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.WallpaperManager; import android.app.WallpaperManager;
import android.appwidget.AppWidgetHostView; import android.appwidget.AppWidgetHostView;
@@ -56,7 +57,6 @@ import android.view.accessibility.AccessibilityManager;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator; import android.view.animation.Interpolator;
import android.widget.TextView; import android.widget.TextView;
import com.android.launcher3.FolderIcon.FolderRingAnimator; import com.android.launcher3.FolderIcon.FolderRingAnimator;
import com.android.launcher3.Launcher.CustomContentCallbacks; import com.android.launcher3.Launcher.CustomContentCallbacks;
import com.android.launcher3.Launcher.LauncherOverlay; import com.android.launcher3.Launcher.LauncherOverlay;
@@ -70,7 +70,6 @@ import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.WallpaperUtils; import com.android.launcher3.util.WallpaperUtils;
import com.android.launcher3.widget.PendingAddShortcutInfo; import com.android.launcher3.widget.PendingAddShortcutInfo;
import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.PendingAddWidgetInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -553,8 +552,10 @@ public class Workspace extends SmoothPagedView
throw new RuntimeException("Screen id " + screenId + " already exists!"); throw new RuntimeException("Screen id " + screenId + " already exists!");
} }
CellLayout newScreen = (CellLayout) // Inflate the cell layout, but do not add it automatically so that we can get the newly
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null); // created CellLayout.
CellLayout newScreen = (CellLayout) mLauncher.getLayoutInflater().inflate(
R.layout.workspace_screen, this, false /* attachToRoot */);
newScreen.setOnLongClickListener(mLongClickListener); newScreen.setOnLongClickListener(mLongClickListener);
newScreen.setOnClickListener(mLauncher); newScreen.setOnClickListener(mLauncher);
@@ -573,7 +574,7 @@ public class Workspace extends SmoothPagedView
public void createCustomContentContainer() { public void createCustomContentContainer() {
CellLayout customScreen = (CellLayout) CellLayout customScreen = (CellLayout)
mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null); mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, this, false);
customScreen.disableBackground(); customScreen.disableBackground();
customScreen.disableDragTarget(); customScreen.disableDragTarget();
@@ -1033,6 +1034,7 @@ public class Workspace extends SmoothPagedView
* listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout * listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout
* that it should intercept touch events, which is not something that is normally supported. * that it should intercept touch events, which is not something that is normally supported.
*/ */
@SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return (workspaceInModalState() || !isFinishedSwitchingState()) return (workspaceInModalState() || !isFinishedSwitchingState())
@@ -1136,7 +1138,7 @@ public class Workspace extends SmoothPagedView
boolean passRightSwipesToCustomContent = boolean passRightSwipesToCustomContent =
(mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY; (mTouchDownTime - mCustomContentShowTime) > CUSTOM_CONTENT_GESTURE_DELAY;
boolean swipeInIgnoreDirection = isLayoutRtl() ? deltaX < 0 : deltaX > 0; boolean swipeInIgnoreDirection = mIsRtl ? deltaX < 0 : deltaX > 0;
boolean onCustomContentScreen = boolean onCustomContentScreen =
getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID; getScreenIdForPageIndex(getCurrentPage()) == CUSTOM_CONTENT_SCREEN_ID;
if (swipeInIgnoreDirection && onCustomContentScreen && passRightSwipesToCustomContent) { if (swipeInIgnoreDirection && onCustomContentScreen && passRightSwipesToCustomContent) {
@@ -1243,15 +1245,14 @@ public class Workspace extends SmoothPagedView
@Override @Override
protected void overScroll(float amount) { protected void overScroll(float amount) {
boolean isRtl = isLayoutRtl(); boolean shouldOverScroll = (amount <= 0 && (!hasCustomContent() || mIsRtl)) ||
boolean shouldOverScroll = (amount <= 0 && (!hasCustomContent() || isRtl)) || (amount >= 0 && (!hasCustomContent() || !mIsRtl));
(amount >= 0 && (!hasCustomContent() || !isRtl));
boolean shouldScrollOverlay = mLauncherOverlay != null && boolean shouldScrollOverlay = mLauncherOverlay != null &&
((amount <= 0 && !isRtl) || (amount >= 0 && isRtl)); ((amount <= 0 && !mIsRtl) || (amount >= 0 && mIsRtl));
boolean shouldZeroOverlay = mLauncherOverlay != null && mLastOverlaySroll != 0 && boolean shouldZeroOverlay = mLauncherOverlay != null && mLastOverlaySroll != 0 &&
((amount >= 0 && !isRtl) || (amount <= 0 && isRtl)); ((amount >= 0 && !mIsRtl) || (amount <= 0 && mIsRtl));
if (shouldScrollOverlay) { if (shouldScrollOverlay) {
if (!mStartedSendingScrollEvents && mScrollInteractionBegan) { if (!mStartedSendingScrollEvents && mScrollInteractionBegan) {
@@ -1265,7 +1266,7 @@ public class Workspace extends SmoothPagedView
int progress = (int) Math.abs((f * 100)); int progress = (int) Math.abs((f * 100));
mLastOverlaySroll = progress; mLastOverlaySroll = progress;
mLauncherOverlay.onScrollChange(progress, isRtl); mLauncherOverlay.onScrollChange(progress, mIsRtl);
} else if (shouldOverScroll) { } else if (shouldOverScroll) {
dampedOverScroll(amount); dampedOverScroll(amount);
mOverScrollEffect = acceleratedOverFactor(amount); mOverScrollEffect = acceleratedOverFactor(amount);
@@ -1274,7 +1275,7 @@ public class Workspace extends SmoothPagedView
} }
if (shouldZeroOverlay) { if (shouldZeroOverlay) {
mLauncherOverlay.onScrollChange(0, isRtl); mLauncherOverlay.onScrollChange(0, mIsRtl);
} }
} }
@@ -1409,7 +1410,7 @@ public class Workspace extends SmoothPagedView
mNumPagesForWallpaperParallax = parallaxPageSpan; mNumPagesForWallpaperParallax = parallaxPageSpan;
if (getChildCount() <= 1) { if (getChildCount() <= 1) {
if (isLayoutRtl()) { if (mIsRtl) {
return 1 - 1.0f/mNumPagesForWallpaperParallax; return 1 - 1.0f/mNumPagesForWallpaperParallax;
} }
return 0; return 0;
@@ -1420,7 +1421,7 @@ public class Workspace extends SmoothPagedView
int firstIndex = numCustomPages(); int firstIndex = numCustomPages();
// Exclude the last extra empty screen (if we have > MIN_PARALLAX_PAGE_SPAN pages) // Exclude the last extra empty screen (if we have > MIN_PARALLAX_PAGE_SPAN pages)
int lastIndex = getChildCount() - 1 - emptyExtraPages; int lastIndex = getChildCount() - 1 - emptyExtraPages;
if (isLayoutRtl()) { if (mIsRtl) {
int temp = firstIndex; int temp = firstIndex;
firstIndex = lastIndex; firstIndex = lastIndex;
lastIndex = temp; lastIndex = temp;
@@ -1441,7 +1442,7 @@ public class Workspace extends SmoothPagedView
// On RTL devices, push the wallpaper offset to the right if we don't have enough // On RTL devices, push the wallpaper offset to the right if we don't have enough
// pages (ie if numScrollingPages < MIN_PARALLAX_PAGE_SPAN) // pages (ie if numScrollingPages < MIN_PARALLAX_PAGE_SPAN)
if (!mWallpaperIsLiveWallpaper && numScrollingPages < MIN_PARALLAX_PAGE_SPAN if (!mWallpaperIsLiveWallpaper && numScrollingPages < MIN_PARALLAX_PAGE_SPAN
&& isLayoutRtl()) { && mIsRtl) {
return offset * (parallaxPageSpan - numScrollingPages + 1) / parallaxPageSpan; return offset * (parallaxPageSpan - numScrollingPages + 1) / parallaxPageSpan;
} }
return offset * (numScrollingPages - 1) / parallaxPageSpan; return offset * (numScrollingPages - 1) / parallaxPageSpan;
@@ -1648,7 +1649,7 @@ public class Workspace extends SmoothPagedView
translationX = scrollRange - scrollDelta; translationX = scrollRange - scrollDelta;
progress = (scrollRange - scrollDelta) / scrollRange; progress = (scrollRange - scrollDelta) / scrollRange;
if (isLayoutRtl()) { if (mIsRtl) {
translationX = Math.min(0, translationX); translationX = Math.min(0, translationX);
} else { } else {
translationX = Math.max(0, translationX); translationX = Math.max(0, translationX);
@@ -1702,7 +1703,6 @@ public class Workspace extends SmoothPagedView
@Override @Override
protected void screenScrolled(int screenCenter) { protected void screenScrolled(int screenCenter) {
final boolean isRtl = isLayoutRtl();
super.screenScrolled(screenCenter); super.screenScrolled(screenCenter);
updatePageAlphaValues(screenCenter); updatePageAlphaValues(screenCenter);
@@ -1717,7 +1717,7 @@ public class Workspace extends SmoothPagedView
final int upperIndex = getChildCount() - 1; final int upperIndex = getChildCount() - 1;
final boolean isLeftPage = mOverScrollX < 0; final boolean isLeftPage = mOverScrollX < 0;
index = (!isRtl && isLeftPage) || (isRtl && !isLeftPage) ? lowerIndex : upperIndex; index = (!mIsRtl && isLeftPage) || (mIsRtl && !isLeftPage) ? lowerIndex : upperIndex;
CellLayout cl = (CellLayout) getChildAt(index); CellLayout cl = (CellLayout) getChildAt(index);
float effect = Math.abs(mOverScrollEffect); float effect = Math.abs(mOverScrollEffect);
@@ -16,17 +16,20 @@
package com.android.launcher3.accessibility; package com.android.launcher3.accessibility;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.View; import android.view.View;
import android.view.View.AccessibilityDelegate; import android.view.View.AccessibilityDelegate;
import android.view.accessibility.AccessibilityNodeInfo; import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace; import com.android.launcher3.Workspace;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class OverviewScreenAccessibilityDelegate extends AccessibilityDelegate { public class OverviewScreenAccessibilityDelegate extends AccessibilityDelegate {
private static final int MOVE_BACKWARD = R.id.action_move_screen_backwards; private static final int MOVE_BACKWARD = R.id.action_move_screen_backwards;
@@ -39,7 +42,7 @@ public class OverviewScreenAccessibilityDelegate extends AccessibilityDelegate {
mWorkspace = workspace; mWorkspace = workspace;
Context context = mWorkspace.getContext(); Context context = mWorkspace.getContext();
boolean isRtl = mWorkspace.isLayoutRtl(); boolean isRtl = Utilities.isRtl(context.getResources());
mActions.put(MOVE_BACKWARD, new AccessibilityAction(MOVE_BACKWARD, mActions.put(MOVE_BACKWARD, new AccessibilityAction(MOVE_BACKWARD,
context.getText(isRtl ? R.string.action_move_screen_right : context.getText(isRtl ? R.string.action_move_screen_right :
R.string.action_move_screen_left))); R.string.action_move_screen_left)));
@@ -16,6 +16,7 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.appwidget.AppWidgetHost; import android.appwidget.AppWidgetHost;
import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetManager;
@@ -49,6 +50,7 @@ class AppWidgetManagerCompatV16 extends AppWidgetManagerCompat {
return Utilities.trim(info.label); return Utilities.trim(info.label);
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override @Override
public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info, public boolean bindAppWidgetIdIfAllowed(int appWidgetId, AppWidgetProviderInfo info,
Bundle options) { Bundle options) {
@@ -16,12 +16,14 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.LauncherActivityInfo; import android.content.pm.LauncherActivityInfo;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.UserHandle; import android.os.Build;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class LauncherActivityInfoCompatVL extends LauncherActivityInfoCompat { public class LauncherActivityInfoCompatVL extends LauncherActivityInfoCompat {
private LauncherActivityInfo mLauncherActivityInfo; private LauncherActivityInfo mLauncherActivityInfo;
@@ -16,6 +16,7 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@@ -32,6 +33,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class LauncherAppsCompatVL extends LauncherAppsCompat { public class LauncherAppsCompatVL extends LauncherAppsCompat {
private LauncherApps mLauncherApps; private LauncherApps mLauncherApps;
@@ -16,10 +16,12 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.pm.PackageInstaller; import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionCallback; import android.content.pm.PackageInstaller.SessionCallback;
import android.content.pm.PackageInstaller.SessionInfo; import android.content.pm.PackageInstaller.SessionInfo;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.util.SparseArray; import android.util.SparseArray;
@@ -30,6 +32,7 @@ import com.android.launcher3.util.Thunk;
import java.util.HashMap; import java.util.HashMap;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class PackageInstallerCompatVL extends PackageInstallerCompat { public class PackageInstallerCompatVL extends PackageInstallerCompat {
@Thunk final SparseArray<String> mActiveSessions = new SparseArray<>(); @Thunk final SparseArray<String> mActiveSessions = new SparseArray<>();
@@ -16,10 +16,10 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.Intent; import android.content.Intent;
import android.os.Build; import android.os.Build;
import android.os.UserHandle; import android.os.UserHandle;
import com.android.launcher3.Utilities; import com.android.launcher3.Utilities;
public class UserHandleCompat { public class UserHandleCompat {
@@ -32,6 +32,7 @@ public class UserHandleCompat {
private UserHandleCompat() { private UserHandleCompat() {
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public static UserHandleCompat myUserHandle() { public static UserHandleCompat myUserHandle() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
return new UserHandleCompat(android.os.Process.myUserHandle()); return new UserHandleCompat(android.os.Process.myUserHandle());
@@ -16,14 +16,12 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.os.Build;
import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import java.util.ArrayList; @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
import java.util.List;
public class UserManagerCompatV17 extends UserManagerCompatV16 { public class UserManagerCompatV17 extends UserManagerCompatV16 {
protected UserManager mUserManager; protected UserManager mUserManager;
@@ -17,18 +17,19 @@
package com.android.launcher3.compat; package com.android.launcher3.compat;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.UserHandle; import android.os.UserHandle;
import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherAppState;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public class UserManagerCompatVL extends UserManagerCompatV17 { public class UserManagerCompatVL extends UserManagerCompatV17 {
private static final String USER_CREATION_TIME_KEY = "user_creation_time_"; private static final String USER_CREATION_TIME_KEY = "user_creation_time_";
@@ -15,8 +15,10 @@
*/ */
package com.android.launcher3.widget; package com.android.launcher3.widget;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Build;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.content.res.Resources; import android.content.res.Resources;
import android.support.v7.widget.RecyclerView.Adapter; import android.support.v7.widget.RecyclerView.Adapter;
@@ -27,9 +29,7 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams; import android.view.ViewGroup.MarginLayoutParams;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.android.launcher3.BubbleTextView; import com.android.launcher3.BubbleTextView;
import com.android.launcher3.DeviceProfile; import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DynamicGrid; import com.android.launcher3.DynamicGrid;
import com.android.launcher3.IconCache; import com.android.launcher3.IconCache;
@@ -38,7 +38,6 @@ import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetProviderInfo; import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.WidgetPreviewLoader; import com.android.launcher3.WidgetPreviewLoader;
import java.util.List; import java.util.List;
/** /**
@@ -157,6 +156,7 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
} }
} }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
@Override @Override
public WidgetsRowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { public WidgetsRowViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (DEBUG) { if (DEBUG) {
@@ -167,7 +167,11 @@ public class WidgetsListAdapter extends Adapter<WidgetsRowViewHolder> {
R.layout.widgets_list_row_view, parent, false); R.layout.widgets_list_row_view, parent, false);
LinearLayout cellList = (LinearLayout) container.findViewById(R.id.widgets_cell_list); LinearLayout cellList = (LinearLayout) container.findViewById(R.id.widgets_cell_list);
MarginLayoutParams lp = (MarginLayoutParams) cellList.getLayoutParams(); MarginLayoutParams lp = (MarginLayoutParams) cellList.getLayoutParams();
lp.setMarginStart(mIndent); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
lp.setMarginStart(mIndent);
} else {
lp.leftMargin = mIndent;
}
cellList.setLayoutParams(lp); cellList.setLayoutParams(lp);
return new WidgetsRowViewHolder(container); return new WidgetsRowViewHolder(container);
} }