Merge "Code cleanup" into ub-launcher3-burnaby

This commit is contained in:
Sunny Goyal
2015-06-05 17:40:26 +00:00
committed by Android (Google) Code Review
9 changed files with 23 additions and 116 deletions
+6 -6
View File
@@ -222,8 +222,8 @@ public class FocusHelper {
if (keyCode == KeyEvent.KEYCODE_DPAD_UP &&
!profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout,
true /* hotseat horizontal */, hotseat.getAllAppsButtonRank(),
iconRank == hotseat.getAllAppsButtonRank() /* include all apps icon */);
true /* hotseat horizontal */, profile.inv.hotseatAllAppsRank,
iconRank == profile.inv.hotseatAllAppsRank /* include all apps icon */);
iconIndex += iconParent.getChildCount();
countX = iconLayout.getCountX();
countY = iconLayout.getCountY() + hotseatLayout.getCountY();
@@ -231,8 +231,8 @@ public class FocusHelper {
} else if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT &&
profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout,
false /* hotseat horizontal */, hotseat.getAllAppsButtonRank(),
iconRank == hotseat.getAllAppsButtonRank() /* include all apps icon */);
false /* hotseat horizontal */, profile.inv.hotseatAllAppsRank,
iconRank == profile.inv.hotseatAllAppsRank /* include all apps icon */);
iconIndex += iconParent.getChildCount();
countX = iconLayout.getCountX() + hotseatLayout.getCountX();
countY = iconLayout.getCountY();
@@ -316,13 +316,13 @@ public class FocusHelper {
// with the hotseat.
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && !profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout, true /* horizontal */,
hotseat.getAllAppsButtonRank(),
profile.inv.hotseatAllAppsRank,
!hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */);
countY = countY + 1;
} else if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT &&
profile.isVerticalBarLayout()) {
matrix = FocusLogic.createSparseMatrix(iconLayout, hotseatLayout, false /* horizontal */,
hotseat.getAllAppsButtonRank(),
profile.inv.hotseatAllAppsRank,
!hotseat.hasIcons() /* ignore all apps icon, unless there are no other icons */);
countX = countX + 1;
} else if (keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL) {
+5 -19
View File
@@ -36,8 +36,7 @@ public class Hotseat extends FrameLayout
private int mAllAppsButtonRank;
private boolean mTransposeLayoutWithOrientation;
private boolean mIsLandscape;
private final boolean mHasVerticalHotseat;
public Hotseat(Context context) {
this(context, null);
@@ -49,13 +48,8 @@ public class Hotseat extends FrameLayout
public Hotseat(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
Resources r = context.getResources();
mTransposeLayoutWithOrientation =
r.getBoolean(R.bool.hotseat_transpose_layout_with_orientation);
mIsLandscape = context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
mLauncher = (Launcher) context;
mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
}
CellLayout getLayout() {
@@ -77,26 +71,18 @@ public class Hotseat extends FrameLayout
mContent.setOnLongClickListener(l);
}
private boolean hasVerticalHotseat() {
return (mIsLandscape && mTransposeLayoutWithOrientation);
}
/* Get the orientation invariant order of the item in the hotseat for persistence. */
int getOrderInHotseat(int x, int y) {
return hasVerticalHotseat() ? (mContent.getCountY() - y - 1) : x;
return mHasVerticalHotseat ? (mContent.getCountY() - y - 1) : x;
}
/* Get the orientation specific coordinates given an invariant order in the hotseat. */
int getCellXFromOrder(int rank) {
return hasVerticalHotseat() ? 0 : rank;
return mHasVerticalHotseat ? 0 : rank;
}
int getCellYFromOrder(int rank) {
return hasVerticalHotseat() ? (mContent.getCountY() - (rank + 1)) : 0;
}
public int getAllAppsButtonRank() {
return mAllAppsButtonRank;
return mHasVerticalHotseat ? (mContent.getCountY() - (rank + 1)) : 0;
}
public boolean isAllAppsButtonRank(int rank) {
+8 -32
View File
@@ -1810,16 +1810,17 @@ public class Launcher extends Activity
}
}
private final Handler mHandler = new Handler() {
@Thunk final Handler mHandler = new Handler(new Handler.Callback() {
@Override
public void handleMessage(Message msg) {
public boolean handleMessage(Message msg) {
if (msg.what == ADVANCE_MSG) {
int i = 0;
for (View key: mWidgetsToAdvance.keySet()) {
final View v = key.findViewById(mWidgetsToAdvance.get(key).autoAdvanceViewId);
final int delay = mAdvanceStagger * i;
if (v instanceof Advanceable) {
postDelayed(new Runnable() {
mHandler.postDelayed(new Runnable() {
public void run() {
((Advanceable) v).advance();
}
@@ -1829,8 +1830,9 @@ public class Launcher extends Activity
}
sendAdvanceMessage(mAdvanceInterval);
}
return true;
}
};
});
void addWidgetToAutoAdvanceIfNeeded(View hostView, AppWidgetProviderInfo appWidgetInfo) {
if (appWidgetInfo == null || appWidgetInfo.autoAdvanceViewId == -1) return;
@@ -2345,7 +2347,7 @@ public class Launcher extends Activity
Intent createShortcutIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
createShortcutIntent.setComponent(componentName);
processShortcut(createShortcutIntent);
Utilities.startActivityForResultSafely(this, createShortcutIntent, REQUEST_CREATE_SHORTCUT);
}
/**
@@ -2402,14 +2404,6 @@ public class Launcher extends Activity
}
}
void processShortcut(Intent intent) {
Utilities.startActivityForResultSafely(this, intent, REQUEST_CREATE_SHORTCUT);
}
void processWallpaper(Intent intent) {
startActivityForResult(intent, REQUEST_PICK_WALLPAPER);
}
FolderIcon addFolder(CellLayout layout, long container, final long screenId, int cellX,
int cellY) {
final FolderInfo folderInfo = new FolderInfo();
@@ -2811,20 +2805,10 @@ public class Launcher extends Activity
if (mLauncherCallbacks != null) {
mLauncherCallbacks.onClickSettingsButton(v);
} else {
showSettingsActivity();
startActivity(new Intent(this, SettingsActivity.class));
}
}
public void onTouchDownAllAppsButton(View v) {
// Provide the same haptic feedback that the system offers for virtual keys.
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
public void performHapticFeedbackOnTouchDown(View v) {
// Provide the same haptic feedback that the system offers for virtual keys.
v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY);
}
public View.OnTouchListener getHapticFeedbackTouchListener() {
if (mHapticFeedbackTouchListener == null) {
mHapticFeedbackTouchListener = new View.OnTouchListener() {
@@ -3774,10 +3758,6 @@ public class Launcher extends Activity
@Override
public void bindAddScreens(ArrayList<Long> orderedScreenIds) {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - bindAddScreens()", true);
Launcher.addDumpLog(TAG, "11683562 - orderedScreenIds: " +
TextUtils.join(", ", orderedScreenIds), true);
int count = orderedScreenIds.size();
for (int i = 0; i < count; i++) {
mWorkspace.insertNewWorkspaceScreenBeforeEmptyScreen(orderedScreenIds.get(i));
@@ -4535,10 +4515,6 @@ public class Launcher extends Activity
editor.apply();
}
private void showSettingsActivity() {
startActivity(new Intent(this, SettingsActivity.class));
}
/**
* To be overridden by subclasses to indicate that there is an in-activity full-screen intro
* screen that must be displayed and dismissed.
@@ -1,30 +0,0 @@
/*
* Copyright (C) 2011 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.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
abstract class LauncherAnimatorUpdateListener implements AnimatorUpdateListener {
public void onAnimationUpdate(ValueAnimator animation) {
final float b = (Float) animation.getAnimatedValue();
final float a = 1f - b;
onAnimationUpdate(a, b);
}
abstract void onAnimationUpdate(float a, float b);
}
@@ -41,7 +41,6 @@ public class LauncherAppState {
private final WidgetPreviewLoader mWidgetCache;
private final boolean mIsScreenLarge;
private final float mScreenDensity;
private final int mLongPressTimeout = 300;
private boolean mWallpaperChangedSinceLastCheck;
@@ -89,7 +88,6 @@ public class LauncherAppState {
// set sIsScreenXLarge and mScreenDensity *before* creating icon cache
mIsScreenLarge = isScreenLarge(sContext.getResources());
mScreenDensity = sContext.getResources().getDisplayMetrics().density;
mInvariantDeviceProfile = new InvariantDeviceProfile(sContext);
mIconCache = new IconCache(sContext, mInvariantDeviceProfile);
mWidgetCache = new WidgetPreviewLoader(sContext, mInvariantDeviceProfile, mIconCache);
@@ -180,15 +178,6 @@ public class LauncherAppState {
return res.getBoolean(R.bool.is_large_tablet);
}
public static boolean isScreenLandscape(Context context) {
return context.getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE;
}
public float getScreenDensity() {
return mScreenDensity;
}
public int getLongPressTimeout() {
return mLongPressTimeout;
}
@@ -1140,10 +1140,6 @@ public class LauncherModel extends BroadcastReceiver
* a list of screen ids in the order that they should appear.
*/
void updateWorkspaceScreenOrder(Context context, final ArrayList<Long> screens) {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - updateWorkspaceScreenOrder()", true);
Launcher.addDumpLog(TAG, "11683562 - screens: " + TextUtils.join(", ", screens), true);
final ArrayList<Long> screensCopy = new ArrayList<Long>(screens);
final ContentResolver cr = context.getContentResolver();
final Uri uri = LauncherSettings.WorkspaceScreens.CONTENT_URI;
@@ -1764,9 +1760,6 @@ public class LauncherModel extends BroadcastReceiver
}
private void loadWorkspace() {
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - loadWorkspace()", true);
final long t = DEBUG_LOADERS ? SystemClock.uptimeMillis() : 0;
final Context context = mContext;
@@ -868,8 +868,6 @@ public class LauncherProvider extends ContentProvider {
throw new RuntimeException("Error: max screen id was not initialized");
}
mMaxScreenId += 1;
// Log to disk
Launcher.addDumpLog(TAG, "11683562 - generateNewScreenId(): " + mMaxScreenId, true);
return mMaxScreenId;
}
+1 -1
View File
@@ -3969,7 +3969,7 @@ public class Workspace extends PagedView
@Override
public boolean onEnterScrollArea(int x, int y, int direction) {
// Ignore the scroll area if we are dragging over the hot seat
boolean isPortrait = !LauncherAppState.isScreenLandscape(getContext());
boolean isPortrait = !mLauncher.getDeviceProfile().isLandscape;
if (mLauncher.getHotseat() != null && isPortrait) {
Rect r = new Rect();
mLauncher.getHotseat().getHitRect(r);
@@ -19,6 +19,7 @@ package com.android.launcher3;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.content.Context;
@@ -335,17 +336,11 @@ public class WorkspaceStateTransitionAnimation {
}
if (mOldBackgroundAlphas[i] != 0 ||
mNewBackgroundAlphas[i] != 0) {
ValueAnimator bgAnim =
ValueAnimator bgAnim = ObjectAnimator.ofFloat(cl, "backgroundAlpha",
mOldBackgroundAlphas[i], mNewBackgroundAlphas[i]);
LauncherAnimUtils.ofFloat(cl, 0f, 1f);
bgAnim.setInterpolator(mZoomInInterpolator);
bgAnim.setDuration(duration);
bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
public void onAnimationUpdate(float a, float b) {
cl.setBackgroundAlpha(
a * mOldBackgroundAlphas[i] +
b * mNewBackgroundAlphas[i]);
}
});
mStateAnimator.play(bgAnim);
}
}