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

Commit f4ed293e authored by Garfield Tan's avatar Garfield Tan
Browse files

Deprecate DrawerOpened metric.

Test: Builds.
Bug: 32704901
Change-Id: I705d457ddd178710708a4970380dd92baae7f3e3
(cherry picked from commit 3f54c9c5)
parent 4b4e51c8
Loading
Loading
Loading
Loading
+0 −41
Original line number Diff line number Diff line
@@ -41,34 +41,8 @@ import java.lang.annotation.RetentionPolicy;
public abstract class DrawerController implements DrawerListener {
    public static final String TAG = "DrawerController";

    // Drawer opening triggered by tapping the navigation icon
    public static final int OPENED_HAMBURGER = 0;
    // Drawer opening triggered by swiping right from the edge of the screen
    public static final int OPENED_SWIPE = 1;
    // Mostly programmatically forced drawer opening
    public static final int OPENED_OTHER = 2;

    @IntDef(flag = true, value = {
            OPENED_HAMBURGER,
            OPENED_SWIPE,
            OPENED_OTHER
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface Trigger {}

    public abstract void update();
    /**
     * Toggles the drawer and sets the OPENED_OTHER as the action that causes opening the drawer.
     * @param open
     */
    public abstract void setOpen(boolean open);

    /**
     * Toggles the drawer.
     * @param open
     * @param trigger Indicates what action caused opening the drawer. It is ignored for closing.
     */
    abstract void setOpen(boolean open, @Trigger int trigger);
    public abstract boolean isPresent();
    public abstract boolean isOpen();
    abstract void setTitle(String title);
@@ -129,7 +103,6 @@ public abstract class DrawerController implements DrawerListener {
        private DrawerLayout mLayout;
        private View mDrawer;
        private Toolbar mToolbar;
        private @Trigger int mTrigger = OPENED_OTHER;

        public RuntimeDrawerController(
                DrawerLayout layout,
@@ -185,14 +158,8 @@ public abstract class DrawerController implements DrawerListener {

        @Override
        public void setOpen(boolean open) {
            setOpen(open, OPENED_OTHER);
        }

        @Override
        void setOpen(boolean open, @Trigger int trigger) {
            if (open) {
                mLayout.openDrawer(mDrawer);
                mTrigger = trigger;
            } else {
                mLayout.closeDrawer(mDrawer);
            }
@@ -226,21 +193,16 @@ public abstract class DrawerController implements DrawerListener {
        @Override
        public void onDrawerOpened(View drawerView) {
            mToggle.onDrawerOpened(drawerView);
            Metrics.logDrawerOpened(mToolbar.getContext(), mTrigger);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            mToggle.onDrawerClosed(drawerView);
            mTrigger = OPENED_OTHER;
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            mToggle.onDrawerStateChanged(newState);
            if (newState == DrawerLayout.STATE_DRAGGING) {
                mTrigger = OPENED_SWIPE;
            }
        }
    }

@@ -252,9 +214,6 @@ public abstract class DrawerController implements DrawerListener {
        @Override
        public void setOpen(boolean open) {}

        @Override
        public void setOpen(boolean open, @Trigger int trigger) {}

        @Override
        public boolean isOpen() {
            return false;
+1 −15
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public final class Metrics {
    private static final String COUNT_FILEOP_EXTERNAL = "docsui_fileop_external";
    private static final String COUNT_FILEOP_CANCELED = "docsui_fileop_canceled";
    private static final String COUNT_STARTUP_MS = "docsui_startup_ms";
    private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened";
    @Deprecated private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened";
    private static final String COUNT_USER_ACTION = "docsui_menu_action";
    private static final String COUNT_BROWSE_AT_LOCATION = "docsui_browse_at_location";
    private static final String COUNT_CREATE_AT_LOCATION = "docsui_create_at_location";
@@ -488,20 +488,6 @@ public final class Metrics {
        logHistogram(context, COUNT_ROOT_VISITED_IN_PICKER, sanitizeRoot(info));
    }

    /**
     * Logs a drawer opened event. Call this when the user opens drawer by swipe or by clicking the
     * hamburger icon.
     * @param context
     * @param trigger type of action that opened the drawer
     */
    public static void logDrawerOpened(Context context, @DrawerController.Trigger int trigger) {
        if (trigger == DrawerController.OPENED_HAMBURGER) {
            logHistogram(context, COUNT_DRAWER_OPENED, DRAWER_OPENED_HAMBURGER);
        } else if (trigger == DrawerController.OPENED_SWIPE) {
            logHistogram(context, COUNT_DRAWER_OPENED, DRAWER_OPENED_SWIPE);
        }
    }

    /**
     * Logs file operation stats. Call this when a file operation has completed. The given
     * DocumentInfo is only used to distinguish broad categories of actions (e.g. copying from one
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class NavigationViewManager {

    private void onNavigationIconClicked() {
        if (mDrawer.isPresent()) {
            mDrawer.setOpen(true, DrawerController.OPENED_HAMBURGER);
            mDrawer.setOpen(true);
        }
    }