From 9bc8eba3338455c5d915055e8ba044981c512dfa Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Mon, 21 May 2012 20:36:44 -0700 Subject: Clean up warnings and some private API usage Change-Id: Ic3c0b333942bc3de130e41531017e71358bd5bfb --- .../android/launcher2/AppsCustomizePagedView.java | 8 +---- .../android/launcher2/AppsCustomizeTabHost.java | 6 ---- src/com/android/launcher2/Cling.java | 13 ++------ src/com/android/launcher2/DeleteDropTarget.java | 1 - src/com/android/launcher2/DragLayer.java | 3 -- src/com/android/launcher2/Folder.java | 2 -- .../android/launcher2/InstallShortcutReceiver.java | 1 - src/com/android/launcher2/Launcher.java | 24 +++++++++++---- .../launcher2/LauncherAppWidgetHostView.java | 3 -- src/com/android/launcher2/LauncherProvider.java | 6 ++-- .../launcher2/PagedViewWidgetImageView.java | 16 +++------- src/com/android/launcher2/PreloadReceiver.java | 1 - src/com/android/launcher2/Workspace.java | 35 ---------------------- 13 files changed, 29 insertions(+), 90 deletions(-) (limited to 'src/com') diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 5f81d9c1d..30d3cf8b0 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -35,7 +35,6 @@ import android.graphics.Bitmap.Config; import android.graphics.Canvas; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; -import android.graphics.Insets; import android.graphics.MaskFilter; import android.graphics.Matrix; import android.graphics.Paint; @@ -60,17 +59,16 @@ import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.widget.GridLayout; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.Toast; import com.android.launcher.R; import com.android.launcher2.DropTarget.DragObject; +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.lang.ref.WeakReference; /** * A simple callback interface which also provides the results of the task. @@ -267,7 +265,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Caching private Canvas mCanvas; - private Drawable mDefaultWidgetBackground; private IconCache mIconCache; // Dimens @@ -336,7 +333,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Save the default widget preview background Resources resources = context.getResources(); - mDefaultWidgetBackground = resources.getDrawable(R.drawable.default_widget_preview_holo); mAppIconSize = resources.getDimensionPixelSize(R.dimen.app_icon_size); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppsCustomizePagedView, 0, 0); @@ -1271,7 +1267,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen getResources().getDimensionPixelOffset(R.dimen.shortcut_preview_padding_right); int scaledIconWidth = (maxWidth - paddingLeft - paddingRight); - float scaleSize = scaledIconWidth / (float) mAppIconSize; renderDrawableToBitmap( icon, tempBitmap, paddingLeft, paddingTop, scaledIconWidth, scaledIconWidth); @@ -1359,7 +1354,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen (int) ((previewDrawableHeight - mAppIconSize * iconScale) / 2); if (iconId > 0) icon = mIconCache.getFullResIcon(packageName, iconId); - Resources resources = mLauncher.getResources(); if (icon != null) { renderDrawableToBitmap(icon, defaultPreview, hoffset, yoffset, (int) (mAppIconSize * iconScale), diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java index 6bd97a2f2..4b568dda0 100644 --- a/src/com/android/launcher2/AppsCustomizeTabHost.java +++ b/src/com/android/launcher2/AppsCustomizeTabHost.java @@ -58,8 +58,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona private boolean mResetAfterTransition; private Runnable mRelayoutAndMakeVisible; - private Launcher mLauncher; - public AppsCustomizeTabHost(Context context, AttributeSet attrs) { super(context, attrs); mLayoutInflater = LayoutInflater.from(context); @@ -71,10 +69,6 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona }; } - public void setup(Launcher launcher) { - mLauncher = launcher; - } - /** * Convenience methods to select specific tabs. We want to set the content type immediately * in these cases, but we note that we still call setCurrentTabByTag() so that the tab view diff --git a/src/com/android/launcher2/Cling.java b/src/com/android/launcher2/Cling.java index c83ee2fde..33cb26f0a 100644 --- a/src/com/android/launcher2/Cling.java +++ b/src/com/android/launcher2/Cling.java @@ -31,7 +31,6 @@ import android.util.DisplayMetrics; import android.view.FocusFinder; import android.view.MotionEvent; import android.view.View; -import android.view.accessibility.AccessibilityManager; import android.widget.FrameLayout; import com.android.launcher.R; @@ -83,6 +82,8 @@ public class Cling extends FrameLayout { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Cling, defStyle, 0); mDrawIdentifier = a.getString(R.styleable.Cling_drawIdentifier); a.recycle(); + + setClickable(true); } void init(Launcher l, int[] positionData) { @@ -137,17 +138,9 @@ public class Cling extends FrameLayout { return new int[]{-1, -1}; } - @Override - public View findViewToTakeAccessibilityFocusFromHover(View child, View descendant) { - if (descendant.includeForAccessibility()) { - return descendant; - } - return null; - } - @Override public View focusSearch(int direction) { - return this.focusSearch(null, direction); + return this.focusSearch(this, direction); } @Override diff --git a/src/com/android/launcher2/DeleteDropTarget.java b/src/com/android/launcher2/DeleteDropTarget.java index 949c035ea..39a0b09c7 100644 --- a/src/com/android/launcher2/DeleteDropTarget.java +++ b/src/com/android/launcher2/DeleteDropTarget.java @@ -25,7 +25,6 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.PointF; import android.graphics.Rect; -import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.util.AttributeSet; import android.view.View; diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java index 4be1914e0..0bcd64c41 100644 --- a/src/com/android/launcher2/DragLayer.java +++ b/src/com/android/launcher2/DragLayer.java @@ -24,8 +24,6 @@ import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; import android.content.res.Resources; import android.graphics.Canvas; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; @@ -446,7 +444,6 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang public void animateViewIntoPosition(DragView dragView, final View child, int duration, final Runnable onFinishAnimationRunnable, View anchorView) { ShortcutAndWidgetContainer parentChildren = (ShortcutAndWidgetContainer) child.getParent(); - CellLayout parent = (CellLayout) (CellLayout) parentChildren.getParent(); CellLayout.LayoutParams lp = (CellLayout.LayoutParams) child.getLayoutParams(); parentChildren.measureChild(child); diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index 1163f9ec4..b6aafe49f 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -57,8 +57,6 @@ import java.util.Comparator; public class Folder extends LinearLayout implements DragSource, View.OnClickListener, View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener, View.OnFocusChangeListener { - - @SuppressWarnings("unused") private static final String TAG = "Launcher.Folder"; protected DragController mDragController; diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java index b454afd7f..81824c614 100644 --- a/src/com/android/launcher2/InstallShortcutReceiver.java +++ b/src/com/android/launcher2/InstallShortcutReceiver.java @@ -22,7 +22,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; -import android.os.Debug; import android.widget.Toast; import com.android.launcher.R; diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 28dfd6521..e3f7b75a8 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -61,7 +61,6 @@ import android.os.Handler; import android.os.Message; import android.os.StrictMode; import android.os.SystemClock; -import android.os.SystemProperties; import android.provider.Settings; import android.speech.RecognizerIntent; import android.text.Selection; @@ -99,6 +98,7 @@ import com.android.launcher2.DropTarget.DragObject; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.FileDescriptor; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; @@ -146,6 +146,7 @@ public final class Launcher extends Activity private static final String PREFERENCES = "launcher.preferences"; static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher.force_enable_rotation"; + static final String DUMP_STATE_PROPERTY = "debug.launcher2.dumpstate"; // The Intent extra that defines whether to ignore the launch animation static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION = @@ -308,6 +309,20 @@ public final class Launcher extends Activity int cellY; } + + private boolean doesFileExist(String filename) { + FileInputStream fis = null; + try { + fis = openFileInput(filename); + fis.close(); + return true; + } catch (java.io.FileNotFoundException e) { + return false; + } catch (java.io.IOException e) { + return true; + } + } + @Override protected void onCreate(Bundle savedInstanceState) { if (DEBUG_STRICT_MODE) { @@ -902,7 +917,6 @@ public final class Launcher extends Activity findViewById(R.id.apps_customize_pane); mAppsCustomizeContent = (AppsCustomizePagedView) mAppsCustomizeTabHost.findViewById(R.id.apps_customize_pane_content); - mAppsCustomizeTabHost.setup(this); mAppsCustomizeContent.setup(this, dragController); // Get the all apps button @@ -1746,7 +1760,7 @@ public final class Launcher extends Activity case KeyEvent.KEYCODE_HOME: return true; case KeyEvent.KEYCODE_VOLUME_DOWN: - if (SystemProperties.getInt("debug.launcher2.dumpstate", 0) != 0) { + if (doesFileExist(DUMP_STATE_PROPERTY)) { dumpState(); return true; } @@ -3526,8 +3540,7 @@ public final class Launcher extends Activity } public boolean isRotationEnabled() { - boolean forceEnableRotation = "true".equalsIgnoreCase(SystemProperties.get( - FORCE_ENABLE_ROTATION_PROPERTY, "false")); + boolean forceEnableRotation = doesFileExist(FORCE_ENABLE_ROTATION_PROPERTY); boolean enableRotation = forceEnableRotation || getResources().getBoolean(R.bool.allow_rotation); return enableRotation; @@ -3565,7 +3578,6 @@ public final class Launcher extends Activity cling.init(this, positionData); cling.setVisibility(View.VISIBLE); cling.setLayerType(View.LAYER_TYPE_HARDWARE, null); - cling.requestAccessibilityFocus(); if (animate) { cling.buildLayer(); cling.setAlpha(0f); diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java index 9970c7675..549d3340e 100644 --- a/src/com/android/launcher2/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java @@ -18,9 +18,6 @@ package com.android.launcher2; import android.appwidget.AppWidgetHostView; import android.content.Context; -import android.content.res.Configuration; -import android.os.Bundle; -import android.os.Parcel; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java index 0720259f4..ccc126a11 100644 --- a/src/com/android/launcher2/LauncherProvider.java +++ b/src/com/android/launcher2/LauncherProvider.java @@ -751,12 +751,12 @@ public class LauncherProvider extends ContentProvider { private static final void beginDocument(XmlPullParser parser, String firstElementName) throws XmlPullParserException, IOException { int type; - while ((type = parser.next()) != parser.START_TAG - && type != parser.END_DOCUMENT) { + while ((type = parser.next()) != XmlPullParser.START_TAG + && type != XmlPullParser.END_DOCUMENT) { ; } - if (type != parser.START_TAG) { + if (type != XmlPullParser.START_TAG) { throw new XmlPullParserException("No start tag found"); } diff --git a/src/com/android/launcher2/PagedViewWidgetImageView.java b/src/com/android/launcher2/PagedViewWidgetImageView.java index 22db0abd8..992817786 100644 --- a/src/com/android/launcher2/PagedViewWidgetImageView.java +++ b/src/com/android/launcher2/PagedViewWidgetImageView.java @@ -18,12 +18,9 @@ package com.android.launcher2; import android.content.Context; import android.graphics.Canvas; -import android.graphics.Insets; import android.util.AttributeSet; import android.widget.ImageView; - - class PagedViewWidgetImageView extends ImageView { public boolean mAllowRequestLayout = true; @@ -39,16 +36,11 @@ class PagedViewWidgetImageView extends ImageView { @Override protected void onDraw(Canvas canvas) { - - Insets insets = Insets.NONE; - if (getBackground() != null) { - insets = getBackground().getLayoutInsets(); - } canvas.save(); - canvas.clipRect(getScrollX() + getPaddingLeft() + insets.left, - getScrollY() + getPaddingTop() + insets.top, - getScrollX() + getRight() - getLeft() - getPaddingRight() - insets.right, - getScrollY() + getBottom() - getTop() - getPaddingBottom() - insets.bottom); + canvas.clipRect(getScrollX() + getPaddingLeft(), + getScrollY() + getPaddingTop(), + getScrollX() + getRight() - getLeft() - getPaddingRight(), + getScrollY() + getBottom() - getTop() - getPaddingBottom()); super.onDraw(canvas); canvas.restore(); diff --git a/src/com/android/launcher2/PreloadReceiver.java b/src/com/android/launcher2/PreloadReceiver.java index d1bc6393d..7bec72117 100644 --- a/src/com/android/launcher2/PreloadReceiver.java +++ b/src/com/android/launcher2/PreloadReceiver.java @@ -19,7 +19,6 @@ package com.android.launcher2; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; -import android.util.Log; public class PreloadReceiver extends BroadcastReceiver { @Override diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 0192630b6..e18d8effd 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -24,7 +24,6 @@ import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.WallpaperManager; import android.appwidget.AppWidgetHostView; -import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.ComponentName; import android.content.Context; @@ -33,7 +32,6 @@ import android.content.SharedPreferences; import android.content.res.Resources; import android.content.res.TypedArray; import android.graphics.Bitmap; -import android.graphics.Camera; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.Paint; @@ -62,7 +60,6 @@ import com.android.launcher2.LauncherSettings.Favorites; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.Set; /** @@ -179,11 +176,6 @@ public class Workspace extends SmoothPagedView public static final int DRAG_BITMAP_PADDING = 2; private boolean mWorkspaceFadeInAdjacentScreens; - // Camera and Matrix used to determine the final position of a neighboring CellLayout - private final Matrix mMatrix = new Matrix(); - private final Camera mCamera = new Camera(); - private final float mTempFloat2[] = new float[2]; - enum WallpaperVerticalOffset { TOP, MIDDLE, BOTTOM }; int mWallpaperWidth; int mWallpaperHeight; @@ -1179,31 +1171,6 @@ public class Workspace extends SmoothPagedView return mBackgroundAlpha; } - /** - * Due to 3D transformations, if two CellLayouts are theoretically touching each other, - * on the xy plane, when one is rotated along the y-axis, the gap between them is perceived - * as being larger. This method computes what offset the rotated view should be translated - * in order to minimize this perceived gap. - * @param degrees Angle of the view - * @param width Width of the view - * @param height Height of the view - * @return Offset to be used in a View.setTranslationX() call - */ - private float getOffsetXForRotation(float degrees, int width, int height) { - mMatrix.reset(); - mCamera.save(); - mCamera.rotateY(Math.abs(degrees)); - mCamera.getMatrix(mMatrix); - mCamera.restore(); - - mMatrix.preTranslate(-width * 0.5f, -height * 0.5f); - mMatrix.postTranslate(width * 0.5f, height * 0.5f); - mTempFloat2[0] = width; - mTempFloat2[1] = height; - mMatrix.mapPoints(mTempFloat2); - return (width - mTempFloat2[0]) * (degrees > 0.0f ? 1.0f : -1.0f); - } - float backgroundAlphaInterpolator(float r) { float pivotA = 0.1f; float pivotB = 0.4f; @@ -3573,8 +3540,6 @@ public class Workspace extends SmoothPagedView } void removeItems(final ArrayList apps) { - final AppWidgetManager widgets = AppWidgetManager.getInstance(getContext()); - final HashSet packageNames = new HashSet(); final int appCount = apps.size(); for (int i = 0; i < appCount; i++) { -- cgit v1.2.3