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