summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-14 00:07:08 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-05-14 12:28:07 -0700
commit7066003b2032a49ae5e59dab9b706259bdeb7e6e (patch)
tree3e3720740c905cf22dc1c96e6123c1bb7bec60e5
parent5a92b2356f1c5f79207c4e9bd47d7b0b5bcf6f78 (diff)
downloadandroid_packages_apps_Trebuchet-7066003b2032a49ae5e59dab9b706259bdeb7e6e.tar.gz
android_packages_apps_Trebuchet-7066003b2032a49ae5e59dab9b706259bdeb7e6e.tar.bz2
android_packages_apps_Trebuchet-7066003b2032a49ae5e59dab9b706259bdeb7e6e.zip
Various lint error fixes.
> Fixing some RTL errors by specifying both marginStart and marginLeft > Moving all layout direction checks to Utilities > Explicitely adding @TargetApi before every method Change-Id: Ibe9c52b93b5a6adeadb27ace2b312770fd732ea0
-rw-r--r--WallpaperPicker/src/com/android/gallery3d/exif/ExifInterface.java6
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java8
-rw-r--r--WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java4
-rw-r--r--res/layout-land/launcher.xml1
-rw-r--r--res/layout-land/migration_cling.xml1
-rw-r--r--res/layout-port/migration_cling.xml1
-rw-r--r--res/layout/apps_list_view.xml2
-rw-r--r--res/layout/search_drop_target_bar.xml3
-rw-r--r--res/layout/widgets_list_row_view.xml1
-rw-r--r--res/values-land/styles.xml2
-rw-r--r--res/values-sw720dp/styles.xml2
-rw-r--r--res/values/styles.xml4
-rw-r--r--src/com/android/launcher3/AppsContainerRecyclerView.java6
-rw-r--r--src/com/android/launcher3/AppsContainerView.java12
-rw-r--r--src/com/android/launcher3/BubbleTextView.java11
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java15
-rw-r--r--src/com/android/launcher3/DeviceProfile.java6
-rw-r--r--src/com/android/launcher3/DragController.java7
-rw-r--r--src/com/android/launcher3/DragLayer.java14
-rw-r--r--src/com/android/launcher3/DragView.java1
-rw-r--r--src/com/android/launcher3/Folder.java13
-rw-r--r--src/com/android/launcher3/FolderPagedView.java8
-rw-r--r--src/com/android/launcher3/InfoDropTarget.java16
-rw-r--r--src/com/android/launcher3/Launcher.java4
-rw-r--r--src/com/android/launcher3/LauncherAnimUtils.java4
-rw-r--r--src/com/android/launcher3/LauncherAppWidgetProviderInfo.java5
-rw-r--r--src/com/android/launcher3/LauncherClings.java4
-rw-r--r--src/com/android/launcher3/LauncherStateTransitionAnimation.java6
-rw-r--r--src/com/android/launcher3/MemoryTracker.java2
-rw-r--r--src/com/android/launcher3/PagedView.java45
-rw-r--r--src/com/android/launcher3/ShortcutAndWidgetContainer.java6
-rw-r--r--src/com/android/launcher3/UninstallDropTarget.java3
-rw-r--r--src/com/android/launcher3/Utilities.java6
-rw-r--r--src/com/android/launcher3/Workspace.java38
-rw-r--r--src/com/android/launcher3/accessibility/OverviewScreenAccessibilityDelegate.java7
-rw-r--r--src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java2
-rw-r--r--src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java4
-rw-r--r--src/com/android/launcher3/compat/LauncherAppsCompatVL.java2
-rw-r--r--src/com/android/launcher3/compat/PackageInstallerCompatVL.java3
-rw-r--r--src/com/android/launcher3/compat/UserHandleCompat.java3
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatV17.java8
-rw-r--r--src/com/android/launcher3/compat/UserManagerCompatVL.java5
-rw-r--r--src/com/android/launcher3/widget/WidgetsListAdapter.java12
43 files changed, 181 insertions, 132 deletions
diff --git a/WallpaperPicker/src/com/android/gallery3d/exif/ExifInterface.java b/WallpaperPicker/src/com/android/gallery3d/exif/ExifInterface.java
index a1cf0fc85..9247e879f 100644
--- a/WallpaperPicker/src/com/android/gallery3d/exif/ExifInterface.java
+++ b/WallpaperPicker/src/com/android/gallery3d/exif/ExifInterface.java
@@ -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]);
}
/**
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
index 142a9cb10..affad0f45 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperCropActivity.java
@@ -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
diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
index 93320919e..1ba5b4b2e 100644
--- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
+++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java
@@ -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
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml
index d5dd91ab4..f0f7bbb9f 100644
--- a/res/layout-land/launcher.xml
+++ b/res/layout-land/launcher.xml
@@ -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"
diff --git a/res/layout-land/migration_cling.xml b/res/layout-land/migration_cling.xml
index db93da87a..269c1aee6 100644
--- a/res/layout-land/migration_cling.xml
+++ b/res/layout-land/migration_cling.xml
@@ -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" >
diff --git a/res/layout-port/migration_cling.xml b/res/layout-port/migration_cling.xml
index 81689d38b..3f696a216 100644
--- a/res/layout-port/migration_cling.xml
+++ b/res/layout-port/migration_cling.xml
@@ -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" >
diff --git a/res/layout/apps_list_view.xml b/res/layout/apps_list_view.xml
index ef20323c1..5e50191ea 100644
--- a/res/layout/apps_list_view.xml
+++ b/res/layout/apps_list_view.xml
@@ -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"
diff --git a/res/layout/search_drop_target_bar.xml b/res/layout/search_drop_target_bar.xml
index 69f42bb4c..b0435aa0e 100644
--- a/res/layout/search_drop_target_bar.xml
+++ b/res/layout/search_drop_target_bar.xml
@@ -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>
diff --git a/res/layout/widgets_list_row_view.xml b/res/layout/widgets_list_row_view.xml
index 2cbdb5cff..be62ee9fc 100644
--- a/res/layout/widgets_list_row_view.xml
+++ b/res/layout/widgets_list_row_view.xml
@@ -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"
diff --git a/res/values-land/styles.xml b/res/values-land/styles.xml
index 8a255c91b..c5a76d595 100644
--- a/res/values-land/styles.xml
+++ b/res/values-land/styles.xml
@@ -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>
diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml
index cbc1e29b3..e8b706e23 100644
--- a/res/values-sw720dp/styles.xml
+++ b/res/values-sw720dp/styles.xml
@@ -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>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 78cc0837f..f95debeab 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -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>
diff --git a/src/com/android/launcher3/AppsContainerRecyclerView.java b/src/com/android/launcher3/AppsContainerRecyclerView.java
index 34e621a46..d35f99d73 100644
--- a/src/com/android/launcher3/AppsContainerRecyclerView.java
+++ b/src/com/android/launcher3/AppsContainerRecyclerView.java
@@ -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) {
diff --git a/src/com/android/launcher3/AppsContainerView.java b/src/com/android/launcher3/AppsContainerView.java
index a74670be0..b752905a2 100644
--- a/src/com/android/launcher3/AppsContainerView.java
+++ b/src/com/android/launcher3/AppsContainerView.java
@@ -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,
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index d32c91919..bbcd893f2 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -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;
}
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 683c511da..b8214d1ef 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -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 {
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 890b9c9d8..33c3d508c 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -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;
diff --git a/src/com/android/launcher3/DragController.java b/src/com/android/launcher3/DragController.java
index 5fea9d889..f5c29ae0a 100644
--- a/src/com/android/launcher3/DragController.java
+++ b/src/com/android/launcher3/DragController.java
@@ -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) {
diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java
index 8ba25da69..e25e6152c 100644
--- a/src/com/android/launcher3/DragLayer.java
+++ b/src/com/android/launcher3/DragLayer.java
@@ -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() ?
diff --git a/src/com/android/launcher3/DragView.java b/src/com/android/launcher3/DragView.java
index 3eec3d9ee..120299e1d 100644
--- a/src/com/android/launcher3/DragView.java
+++ b/src/com/android/launcher3/DragView.java
@@ -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);
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index 6e5941cf2..131633c1d 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -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();
diff --git a/src/com/android/launcher3/FolderPagedView.java b/src/com/android/launcher3/FolderPagedView.java
index a6494d274..94c016dd3 100644
--- a/src/com/android/launcher3/FolderPagedView.java
+++ b/src/com/android/launcher3/FolderPagedView.java
@@ -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);
diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java
index f1ff48da3..f3383ccea 100644
--- a/src/com/android/launcher3/InfoDropTarget.java
+++ b/src/com/android/launcher3/InfoDropTarget.java
@@ -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
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8603a35df..72472b9f4 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -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) {
diff --git a/src/com/android/launcher3/LauncherAnimUtils.java b/src/com/android/launcher3/LauncherAnimUtils.java
index be295f8b3..6ff76665c 100644
--- a/src/com/android/launcher3/LauncherAnimUtils.java
+++ b/src/com/android/launcher3/LauncherAnimUtils.java
@@ -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,
diff --git a/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java b/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
index af680f247..e19bc9534 100644
--- a/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
+++ b/src/com/android/launcher3/LauncherAppWidgetProviderInfo.java
@@ -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);
diff --git a/src/com/android/launcher3/LauncherClings.java b/src/com/android/launcher3/LauncherClings.java
index a2c56a91c..63d3ebc23 100644
--- a/src/com/android/launcher3/LauncherClings.java
+++ b/src/com/android/launcher3/LauncherClings.java
@@ -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;
diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
index 73ae51c3e..324375444 100644
--- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java
+++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java
@@ -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) {
diff --git a/src/com/android/launcher3/MemoryTracker.java b/src/com/android/launcher3/MemoryTracker.java
index 2d37c809e..067a50f97 100644
--- a/src/com/android/launcher3/MemoryTracker.java
+++ b/src/com/android/launcher3/MemoryTracker.java
@@ -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;
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index c8e7d9c0b..939615bbb 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -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();
}
@@ -403,13 +405,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.
*/
int getCurrentPage() {
@@ -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();
diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
index 56c8b39b6..490ed6a73 100644
--- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java
+++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java
@@ -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
diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java
index c3511358d..0fc8f324a 100644
--- a/src/com/android/launcher3/UninstallDropTarget.java
+++ b/src/com/android/launcher3/UninstallDropTarget.java
@@ -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);
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 298174768..f3435fc5c 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -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);
+ }
}
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 4004b1d90..58e5877a6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -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);
diff --git a/src/com/android/launcher3/accessibility/OverviewScreenAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/OverviewScreenAccessibilityDelegate.java
index d3f5230b2..c5b52de72 100644
--- a/src/com/android/launcher3/accessibility/OverviewScreenAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/OverviewScreenAccessibilityDelegate.java
@@ -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)));
diff --git a/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java b/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
index 967b53b0b..8cecb9602 100644
--- a/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
+++ b/src/com/android/launcher3/compat/AppWidgetManagerCompatV16.java
@@ -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) {
diff --git a/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java b/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java
index b52cf1de2..4448758e7 100644
--- a/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java
+++ b/src/com/android/launcher3/compat/LauncherActivityInfoCompatVL.java
@@ -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;
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
index e0d28b566..c862ffc0a 100644
--- a/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
+++ b/src/com/android/launcher3/compat/LauncherAppsCompatVL.java
@@ -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;
diff --git a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
index 395d5f9e2..3ad51017d 100644
--- a/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
+++ b/src/com/android/launcher3/compat/PackageInstallerCompatVL.java
@@ -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<>();
diff --git a/src/com/android/launcher3/compat/UserHandleCompat.java b/src/com/android/launcher3/compat/UserHandleCompat.java
index 2ae673171..d8e60b875 100644
--- a/src/com/android/launcher3/compat/UserHandleCompat.java
+++ b/src/com/android/launcher3/compat/UserHandleCompat.java
@@ -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());
diff --git a/src/com/android/launcher3/compat/UserManagerCompatV17.java b/src/com/android/launcher3/compat/UserManagerCompatV17.java
index 055359afe..c42c00c7d 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatV17.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatV17.java
@@ -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;
diff --git a/src/com/android/launcher3/compat/UserManagerCompatVL.java b/src/com/android/launcher3/compat/UserManagerCompatVL.java
index 884d6fe2a..f6434c5b2 100644
--- a/src/com/android/launcher3/compat/UserManagerCompatVL.java
+++ b/src/com/android/launcher3/compat/UserManagerCompatVL.java
@@ -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_";
diff --git a/src/com/android/launcher3/widget/WidgetsListAdapter.java b/src/com/android/launcher3/widget/WidgetsListAdapter.java
index d6e062874..84884c4fa 100644
--- a/src/com/android/launcher3/widget/WidgetsListAdapter.java
+++ b/src/com/android/launcher3/widget/WidgetsListAdapter.java
@@ -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);
}