Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f3e9383 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Code cleanup

> Removing obsolete logging
> Removing unused methods
> Removing resource leak warning due to non-static handler class in launcher

Change-Id: Ic38cc8aea82899b0b5ee3235f04e5964e49245fb
parent 26c2842f
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -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,18 +2805,8 @@ 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() {
@@ -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.
+0 −30
Original line number Diff line number Diff line
/*
 * 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);
}
 No newline at end of file
+0 −11
Original line number Diff line number Diff line
@@ -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;
    }
Loading