From 9c83a0da6d6faf4d8a81effd27997ffb12bf3fdd Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Fri, 13 Feb 2015 10:40:07 -0800 Subject: Cleaning up some resources in WallpaperPickerActivity Change-Id: I4923403c0c094d0ae0b00e3a08a13099c3addb10 --- WallpaperPicker/res/layout/wallpaper_cropper.xml | 3 +- WallpaperPicker/res/layout/wallpaper_picker.xml | 42 +++++++++----- .../layout/wallpaper_picker_image_picker_item.xml | 1 - .../res/layout/wallpaper_picker_item.xml | 1 - .../wallpaper_picker_live_wallpaper_item.xml | 1 - .../layout/wallpaper_picker_third_party_item.xml | 1 - WallpaperPicker/res/values-sw720dp-v19/styles.xml | 2 +- WallpaperPicker/res/values-sw720dp/styles.xml | 2 +- .../launcher3/LiveWallpaperListAdapter.java | 2 - .../ThirdPartyWallpaperPickerListAdapter.java | 2 - .../android/launcher3/WallpaperPickerActivity.java | 64 +++++----------------- .../com/android/launcher3/WallpaperRootView.java | 39 ------------- 12 files changed, 46 insertions(+), 114 deletions(-) delete mode 100644 WallpaperPicker/src/com/android/launcher3/WallpaperRootView.java diff --git a/WallpaperPicker/res/layout/wallpaper_cropper.xml b/WallpaperPicker/res/layout/wallpaper_cropper.xml index abb860898..ffe8df0fb 100644 --- a/WallpaperPicker/res/layout/wallpaper_cropper.xml +++ b/WallpaperPicker/res/layout/wallpaper_cropper.xml @@ -19,7 +19,6 @@ --> - + android:layout_height="match_parent" > + + + android:visibility="invisible" /> + + + - - - - + - + + \ No newline at end of file diff --git a/WallpaperPicker/res/layout/wallpaper_picker_image_picker_item.xml b/WallpaperPicker/res/layout/wallpaper_picker_image_picker_item.xml index ae3c43d8e..dc6524486 100644 --- a/WallpaperPicker/res/layout/wallpaper_picker_image_picker_item.xml +++ b/WallpaperPicker/res/layout/wallpaper_picker_image_picker_item.xml @@ -20,7 +20,6 @@ android:layout_height="@dimen/wallpaperThumbnailHeight" android:focusable="true" android:clickable="true" - android:background="@drawable/wallpaper_tile_fg" android:foreground="@drawable/wallpaper_tile_fg"> - diff --git a/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java b/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java index 0a9050cff..72f2d7e49 100644 --- a/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java +++ b/WallpaperPicker/src/com/android/launcher3/LiveWallpaperListAdapter.java @@ -90,8 +90,6 @@ public class LiveWallpaperListAdapter extends BaseAdapter implements ListAdapter view = convertView; } - WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view); - LiveWallpaperTile wallpaperInfo = mWallpapers.get(position); wallpaperInfo.setView(view); ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image); diff --git a/WallpaperPicker/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java b/WallpaperPicker/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java index 7a4d48ca9..27e65aa31 100644 --- a/WallpaperPicker/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java +++ b/WallpaperPicker/src/com/android/launcher3/ThirdPartyWallpaperPickerListAdapter.java @@ -126,8 +126,6 @@ public class ThirdPartyWallpaperPickerListAdapter extends BaseAdapter implements view = convertView; } - WallpaperPickerActivity.setWallpaperItemPaddingToZero((FrameLayout) view); - ResolveInfo info = mThirdPartyWallpaperPickers.get(position).mResolveInfo; TextView label = (TextView) view.findViewById(R.id.wallpaper_item_label); label.setText(info.loadLabel(mPackageManager)); diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java index cbed61bd2..d16fc31e5 100644 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java +++ b/WallpaperPicker/src/com/android/launcher3/WallpaperPickerActivity.java @@ -34,11 +34,9 @@ import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Point; import android.graphics.PorterDuff; -import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; -import android.graphics.drawable.LevelListDrawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; @@ -95,7 +93,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { private OnClickListener mThumbnailOnClickListener; private LinearLayout mWallpapersView; - private View mWallpaperStrip; + private HorizontalScrollView mWallpaperScrollContainer; private ActionMode.Callback mActionModeCallback; private ActionMode mActionMode; @@ -313,10 +311,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } } - public void setWallpaperStripYOffset(float offset) { - mWallpaperStrip.setPadding(0, 0, 0, (int) offset); - } - /** * shows the system wallpaper behind the window and hides the {@link * #mCropView} if visible @@ -369,9 +363,7 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { mCropView.setVisibility(View.INVISIBLE); mProgressView = findViewById(R.id.loading); - - - mWallpaperStrip = findViewById(R.id.wallpaper_strip); + mWallpaperScrollContainer = (HorizontalScrollView) findViewById(R.id.wallpaper_scroll_container); mCropView.setTouchCallback(new CropView.TouchCallback() { ViewPropertyAnimator mAnim; @Override @@ -379,15 +371,15 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { if (mAnim != null) { mAnim.cancel(); } - if (mWallpaperStrip.getAlpha() == 1f) { + if (mWallpaperScrollContainer.getAlpha() == 1f) { mIgnoreNextTap = true; } - mAnim = mWallpaperStrip.animate(); + mAnim = mWallpaperScrollContainer.animate(); mAnim.alpha(0f) .setDuration(150) .withEndAction(new Runnable() { public void run() { - mWallpaperStrip.setVisibility(View.INVISIBLE); + mWallpaperScrollContainer.setVisibility(View.INVISIBLE); } }); mAnim.setInterpolator(new AccelerateInterpolator(0.75f)); @@ -405,8 +397,8 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { if (mAnim != null) { mAnim.cancel(); } - mWallpaperStrip.setVisibility(View.VISIBLE); - mAnim = mWallpaperStrip.animate(); + mWallpaperScrollContainer.setVisibility(View.VISIBLE); + mAnim = mWallpaperScrollContainer.animate(); mAnim.alpha(1f) .setDuration(150) .setInterpolator(new DecelerateInterpolator(0.75f)); @@ -487,7 +479,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { LinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list); FrameLayout pickImageTile = (FrameLayout) getLayoutInflater(). inflate(R.layout.wallpaper_picker_image_picker_item, masterWallpaperList, false); - setWallpaperItemPaddingToZero(pickImageTile); masterWallpaperList.addView(pickImageTile, 0); // Make its background the last photo taken on external storage @@ -659,17 +650,14 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } private void initializeScrollForRtl() { - final HorizontalScrollView scroll = - (HorizontalScrollView) findViewById(R.id.wallpaper_scroll_container); - - if (scroll.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { - final ViewTreeObserver observer = scroll.getViewTreeObserver(); + if (mWallpaperScrollContainer.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL) { + final ViewTreeObserver observer = mWallpaperScrollContainer.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { public void onGlobalLayout() { LinearLayout masterWallpaperList = (LinearLayout) findViewById(R.id.master_wallpaper_list); - scroll.scrollTo(masterWallpaperList.getWidth(), 0); - scroll.getViewTreeObserver().removeOnGlobalLayoutListener(this); + mWallpaperScrollContainer.scrollTo(masterWallpaperList.getWidth(), 0); + mWallpaperScrollContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this); } }); } @@ -696,10 +684,10 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { protected void onStop() { super.onStop(); - mWallpaperStrip = findViewById(R.id.wallpaper_strip); - if (mWallpaperStrip.getAlpha() < 1f) { - mWallpaperStrip.setAlpha(1f); - mWallpaperStrip.setVisibility(View.VISIBLE); + mWallpaperScrollContainer = (HorizontalScrollView) findViewById(R.id.wallpaper_scroll_container); + if (mWallpaperScrollContainer.getAlpha() < 1f) { + mWallpaperScrollContainer.setAlpha(1f); + mWallpaperScrollContainer.setVisibility(View.VISIBLE); } } @@ -823,7 +811,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { final FrameLayout pickedImageThumbnail = (FrameLayout) getLayoutInflater(). inflate(R.layout.wallpaper_picker_item, mWallpapersView, false); pickedImageThumbnail.setVisibility(View.GONE); - setWallpaperItemPaddingToZero(pickedImageThumbnail); mWallpapersView.addView(pickedImageThumbnail, 0); // Load the thumbnail @@ -886,11 +873,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { } } - static void setWallpaperItemPaddingToZero(FrameLayout frameLayout) { - frameLayout.setPadding(0, 0, 0, 0); - frameLayout.setForeground(new ZeroPaddingDrawable(frameLayout.getForeground())); - } - private void addLongPressHandler(View v) { v.setOnLongClickListener(mLongClickListener); } @@ -1089,20 +1071,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { return mSavedImages; } - static class ZeroPaddingDrawable extends LevelListDrawable { - public ZeroPaddingDrawable(Drawable d) { - super(); - addLevel(0, 0, d); - setLevel(0); - } - - @Override - public boolean getPadding(Rect padding) { - padding.set(0, 0, 0, 0); - return true; - } - } - private static class SimpleWallpapersAdapter extends ArrayAdapter { private final LayoutInflater mLayoutInflater; @@ -1130,8 +1098,6 @@ public class WallpaperPickerActivity extends WallpaperCropActivity { view = convertView; } - setWallpaperItemPaddingToZero((FrameLayout) view); - ImageView image = (ImageView) view.findViewById(R.id.wallpaper_image); if (thumb != null) { diff --git a/WallpaperPicker/src/com/android/launcher3/WallpaperRootView.java b/WallpaperPicker/src/com/android/launcher3/WallpaperRootView.java deleted file mode 100644 index ceaa043a7..000000000 --- a/WallpaperPicker/src/com/android/launcher3/WallpaperRootView.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher3; - -import android.content.Context; -import android.graphics.Rect; -import android.util.AttributeSet; -import android.widget.RelativeLayout; - -public class WallpaperRootView extends RelativeLayout { - private final WallpaperPickerActivity a; - public WallpaperRootView(Context context, AttributeSet attrs) { - super(context, attrs); - a = (WallpaperPickerActivity) context; - } - public WallpaperRootView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - a = (WallpaperPickerActivity) context; - } - - protected boolean fitSystemWindows(Rect insets) { - a.setWallpaperStripYOffset(insets.bottom); - return true; - } -} -- cgit v1.2.3