Merge "Cleaning up some resources in WallpaperPickerActivity" into ub-launcher3-burnaby
This commit is contained in:
@@ -19,7 +19,6 @@
|
||||
-->
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/wallpaper_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<com.android.launcher3.CropView
|
||||
@@ -28,7 +27,7 @@
|
||||
android:layout_height="match_parent" />
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
style="@android:style/Widget.Holo.ProgressBar.Large"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:visibility="invisible"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -18,60 +18,74 @@
|
||||
*/
|
||||
-->
|
||||
|
||||
<com.android.launcher3.WallpaperRootView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/wallpaper_root"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:launcher="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<com.android.launcher3.CropView
|
||||
android:id="@+id/cropView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
style="@android:style/Widget.Holo.ProgressBar.Large"
|
||||
android:visibility="invisible"
|
||||
style="?android:attr/progressBarStyleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:indeterminate="true"
|
||||
android:indeterminateOnly="true"
|
||||
android:background="@android:color/transparent" />
|
||||
android:visibility="invisible" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/wallpaper_strip"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_gravity="bottom"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@drawable/tile_shadow_top" />
|
||||
|
||||
<HorizontalScrollView
|
||||
android:id="@+id/wallpaper_scroll_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
<LinearLayout android:id="@+id/master_wallpaper_list"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/master_wallpaper_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
<LinearLayout android:id="@+id/wallpaper_list"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/wallpaper_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
<LinearLayout android:id="@+id/live_wallpaper_list"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/live_wallpaper_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
<LinearLayout android:id="@+id/third_party_wallpaper_list"
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/third_party_wallpaper_list"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" />
|
||||
</LinearLayout>
|
||||
</HorizontalScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:background="@drawable/tile_shadow_bottom" />
|
||||
</LinearLayout>
|
||||
</com.android.launcher3.WallpaperRootView>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -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">
|
||||
<ImageView
|
||||
android:id="@+id/wallpaper_image"
|
||||
|
||||
@@ -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">
|
||||
<ImageView
|
||||
android:id="@+id/wallpaper_image"
|
||||
|
||||
@@ -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">
|
||||
<ImageView
|
||||
android:id="@+id/wallpaper_image"
|
||||
|
||||
@@ -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">
|
||||
<ImageView
|
||||
android:id="@+id/wallpaper_image"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
|
||||
<style name="Theme" parent="@android:style/Theme.DeviceDefault.Wallpaper.NoTitleBar">
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
|
||||
<style name="Theme" parent="@android:style/Theme.DeviceDefault.Wallpaper.NoTitleBar">
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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<WallpaperTileInfo> {
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user