summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/AppDrawerListAdapter.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/AppDrawerListAdapter.java')
-rw-r--r--src/com/android/launcher3/AppDrawerListAdapter.java77
1 files changed, 62 insertions, 15 deletions
diff --git a/src/com/android/launcher3/AppDrawerListAdapter.java b/src/com/android/launcher3/AppDrawerListAdapter.java
index 21c1b28e9..25c6bb793 100644
--- a/src/com/android/launcher3/AppDrawerListAdapter.java
+++ b/src/com/android/launcher3/AppDrawerListAdapter.java
@@ -24,14 +24,16 @@ import android.content.Context;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.provider.Settings;
+import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.support.v7.widget.RecyclerView;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
+import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.SectionIndexer;
import com.android.launcher3.locale.LocaleSetManager;
@@ -51,6 +53,7 @@ import java.util.List;
public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdapter.ViewHolder>
implements View.OnLongClickListener, DragSource, SectionIndexer {
+ private static final String TAG = AppDrawerListAdapter.class.getSimpleName();
private static final String NUMERIC_OR_SPECIAL_HEADER = "#";
/**
@@ -110,14 +113,17 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
public static class ViewHolder extends RecyclerView.ViewHolder {
public AutoFitTextView mTextView;
public ViewGroup mLayout;
- public View mFadingBackgroundFront;
- public View mFadingBackgroundBack;
+ public View mContainerView;
+ public View mFadingBackgroundBackView;
+ public View mFadingBackgroundFrontView;
public ViewHolder(View itemView) {
super(itemView);
+ mContainerView = itemView;
+ mFadingBackgroundBackView = itemView.findViewById(R.id.fading_background_back);
+ mFadingBackgroundFrontView = itemView.findViewById(R.id.fading_background_front);
mTextView = (AutoFitTextView) itemView.findViewById(R.id.drawer_item_title);
+ mTextView.bringToFront();
mLayout = (ViewGroup) itemView.findViewById(R.id.drawer_item_flow);
- mFadingBackgroundFront = itemView.findViewById(R.id.fading_background_front);
- mFadingBackgroundBack = itemView.findViewById(R.id.fading_background_back);
}
}
@@ -158,6 +164,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
mViewHolderSet = new HashSet<>();
mInterpolator = new DecelerateInterpolator();
YDPI = ctx.getResources().getDisplayMetrics().ydpi;
+
mLayoutChangeListener = new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
@@ -288,19 +295,22 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
percentage = 1 - percentage;
}
+ // Scale header text letters
final float targetScale = (MAX_SCALE - MIN_SCALE) * percentage + MIN_SCALE;
holder.mTextView.setScaleX(targetScale);
holder.mTextView.setScaleY(targetScale);
+ // Perform animation
if (getSectionForPosition(holder.getPosition()) == mSectionTarget) {
- holder.mFadingBackgroundFront.setVisibility(View.INVISIBLE);
- holder.mFadingBackgroundBack.setAlpha(percentage);
- holder.mFadingBackgroundBack.setVisibility(View.VISIBLE);
+ holder.mFadingBackgroundFrontView.setVisibility(View.INVISIBLE);
+ holder.mFadingBackgroundBackView.setAlpha(percentage);
+ holder.mFadingBackgroundBackView.setVisibility(View.VISIBLE);
} else {
- holder.mFadingBackgroundFront.setAlpha(percentage);
- holder.mFadingBackgroundFront.setVisibility(View.VISIBLE);
- holder.mFadingBackgroundBack.setVisibility(View.INVISIBLE);
+ holder.mFadingBackgroundBackView.setVisibility(View.INVISIBLE);
+ holder.mFadingBackgroundFrontView.setAlpha(percentage);
+ holder.mFadingBackgroundFrontView.setVisibility(View.VISIBLE);
}
+
}
/**
@@ -314,7 +324,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
}
}
- private static class ItemAnimator implements ValueAnimator.AnimatorUpdateListener {
+ private class ItemAnimator implements ValueAnimator.AnimatorUpdateListener {
private ViewHolder mViewHolder;
private ItemAnimatorSet mAnimatorSet;
@@ -325,7 +335,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
@Override
public void onAnimationUpdate(ValueAnimator animation) {
- mAnimatorSet.animate(mViewHolder, animation);
+ mItemAnimatorSet.animate(mViewHolder, animation);
}
}
@@ -365,9 +375,25 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
private void initParams() {
mDeviceProfile = LauncherAppState.getInstance().getDynamicGrid().getDeviceProfile();
- int width = mDeviceProfile.cellWidthPx + 2 * mDeviceProfile.edgeMarginPx;
+ int width = mDeviceProfile.allAppsIconSizePx + 2 * mDeviceProfile.edgeMarginPx;
+ int drawnWidth = (mDeviceProfile.allAppsCellWidthPx * mDeviceProfile.numColumnsBase) +
+ ((mDeviceProfile.edgeMarginPx * 2) * mDeviceProfile.numColumnsBase);
+
mIconParams = new
LinearLayout.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT);
+
+ boolean isLarge = SettingsProvider.getBoolean(mLauncher,
+ SettingsProvider.SETTINGS_UI_GENERAL_ICONS_LARGE,
+ R.bool.preferences_interface_general_icons_large_default);
+
+ if (!isLarge) {
+ mIconParams.setMarginStart(mDeviceProfile.edgeMarginPx);
+ mIconParams.setMarginEnd(mDeviceProfile.edgeMarginPx);
+ }
+
+ mIconParams.topMargin = mDeviceProfile.edgeMarginPx;
+ mIconParams.bottomMargin = mDeviceProfile.edgeMarginPx;
+ mIconParams.gravity = Gravity.CENTER;
mIconRect = new Rect(0, 0, mDeviceProfile.allAppsIconSizePx,
mDeviceProfile.allAppsIconSizePx);
@@ -470,6 +496,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
ArrayList<AppInfo> infos = getAllApps();
mLauncher.mAppDrawer.getLayoutManager().removeAllViews();
+
setApps(infos);
}
@@ -662,6 +689,7 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
holder.mTextView.setPivotY(holder.mTextView.getHeight() / 2);
final int size = indexedInfo.mInfo.size();
+
for (int i = 0; i < holder.mLayout.getChildCount(); i++) {
AppDrawerIconView icon = (AppDrawerIconView) holder.mLayout.getChildAt(i);
icon.setLayoutParams(mIconParams);
@@ -816,7 +844,26 @@ public class AppDrawerListAdapter extends RecyclerView.Adapter<AppDrawerListAdap
@Override
public int getSectionForPosition(int position) {
- return mSectionHeaders.get(mHeaderList.get(position).mStartString).mSectionIndex;
+ if (mSectionHeaders == null) {
+ return 0;
+ }
+
+ position = (position < 0) ? 0 : position;
+ position = (position > mHeaderList.size()) ? mHeaderList.size() : position;
+
+ int index = 0;
+ AppItemIndexedInfo info = mHeaderList.get(position);
+ if (info != null) {
+ SectionIndices indices = mSectionHeaders.get(info.mStartString);
+ if (indices != null) {
+ index = indices.mSectionIndex;
+ } else {
+ Log.w(TAG, "SectionIndices are null");
+ }
+ } else {
+ Log.w(TAG, "AppItemIndexedInfo is null");
+ }
+ return index;
}
private void filterProtectedApps(ArrayList<AppInfo> list) {