Loading src/com/android/documentsui/DrawerController.java +44 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.documentsui; import static com.android.documentsui.Shared.DEBUG; import android.annotation.IntDef; import android.app.Activity; import android.content.Context; import android.support.v4.app.ActionBarDrawerToggle; Loading @@ -27,16 +28,44 @@ import android.util.Log; import android.view.View; import android.widget.Toolbar; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * A facade over the various pieces comprising "roots fragment in a Drawer". * * @see DrawerController#create(DrawerLayout) */ 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 {} /** * Toggles the drawer and sets the OPENED_OTHER as the action that causes opening the drawer. * @param open */ 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); abstract boolean isPresent(); abstract boolean isOpen(); abstract void setTitle(String title); Loading Loading @@ -92,11 +121,11 @@ abstract class DrawerController implements DrawerListener { * Runtime controller that manages a real drawer. */ private static final class RuntimeDrawerController extends DrawerController { private final ActionBarDrawerToggle mToggle; private DrawerLayout mLayout; private View mDrawer; private Toolbar mToolbar; private @Trigger int mTrigger = OPENED_OTHER; public RuntimeDrawerController( DrawerLayout layout, View drawer, ActionBarDrawerToggle toggle, Loading @@ -113,8 +142,14 @@ abstract class DrawerController implements DrawerListener { @Override 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); } Loading Loading @@ -148,16 +183,21 @@ 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; } } } Loading @@ -169,6 +209,8 @@ abstract class DrawerController implements DrawerListener { @Override void setOpen(boolean open) {} @Override void setOpen(boolean open, @Trigger int trigger) {} @Override boolean isOpen() { Loading src/com/android/documentsui/Metrics.java +30 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,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"; // Indices for bucketing roots in the roots histogram. "Other" is the catch-all index for any // root that is not explicitly recognized by the Metrics code (see {@link Loading Loading @@ -227,6 +228,21 @@ public final class Metrics { @Retention(RetentionPolicy.SOURCE) public @interface Provider {} // Codes representing different actions to open the drawer. They are used for bucketing stats in // the COUNT_DRAWER_OPENED histogram. // Do not change or rearrange these values, that will break historical data. Only add to the // list. // Do not use negative numbers or zero; clearcut only handles positive integers. private static final int DRAWER_OPENED_HAMBURGER = 1; private static final int DRAWER_OPENED_SWIPE = 2; @IntDef(flag = true, value = { DRAWER_OPENED_HAMBURGER, DRAWER_OPENED_SWIPE }) @Retention(RetentionPolicy.SOURCE) public @interface DrawerTrigger {} /** * Logs when DocumentsUI is started, and how. Call this when DocumentsUI first starts up. * Loading Loading @@ -286,6 +302,20 @@ public final class Metrics { logCount(context, COUNT_MULTI_WINDOW); } /** * 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 Loading src/com/android/documentsui/NavigationView.java +1 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ class NavigationView { private void onNavigationIconClicked() { if (mDrawer.isPresent()) { mDrawer.setOpen(true); mDrawer.setOpen(true, DrawerController.OPENED_HAMBURGER); } } Loading Loading
src/com/android/documentsui/DrawerController.java +44 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.documentsui; import static com.android.documentsui.Shared.DEBUG; import android.annotation.IntDef; import android.app.Activity; import android.content.Context; import android.support.v4.app.ActionBarDrawerToggle; Loading @@ -27,16 +28,44 @@ import android.util.Log; import android.view.View; import android.widget.Toolbar; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * A facade over the various pieces comprising "roots fragment in a Drawer". * * @see DrawerController#create(DrawerLayout) */ 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 {} /** * Toggles the drawer and sets the OPENED_OTHER as the action that causes opening the drawer. * @param open */ 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); abstract boolean isPresent(); abstract boolean isOpen(); abstract void setTitle(String title); Loading Loading @@ -92,11 +121,11 @@ abstract class DrawerController implements DrawerListener { * Runtime controller that manages a real drawer. */ private static final class RuntimeDrawerController extends DrawerController { private final ActionBarDrawerToggle mToggle; private DrawerLayout mLayout; private View mDrawer; private Toolbar mToolbar; private @Trigger int mTrigger = OPENED_OTHER; public RuntimeDrawerController( DrawerLayout layout, View drawer, ActionBarDrawerToggle toggle, Loading @@ -113,8 +142,14 @@ abstract class DrawerController implements DrawerListener { @Override 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); } Loading Loading @@ -148,16 +183,21 @@ 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; } } } Loading @@ -169,6 +209,8 @@ abstract class DrawerController implements DrawerListener { @Override void setOpen(boolean open) {} @Override void setOpen(boolean open, @Trigger int trigger) {} @Override boolean isOpen() { Loading
src/com/android/documentsui/Metrics.java +30 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,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"; // Indices for bucketing roots in the roots histogram. "Other" is the catch-all index for any // root that is not explicitly recognized by the Metrics code (see {@link Loading Loading @@ -227,6 +228,21 @@ public final class Metrics { @Retention(RetentionPolicy.SOURCE) public @interface Provider {} // Codes representing different actions to open the drawer. They are used for bucketing stats in // the COUNT_DRAWER_OPENED histogram. // Do not change or rearrange these values, that will break historical data. Only add to the // list. // Do not use negative numbers or zero; clearcut only handles positive integers. private static final int DRAWER_OPENED_HAMBURGER = 1; private static final int DRAWER_OPENED_SWIPE = 2; @IntDef(flag = true, value = { DRAWER_OPENED_HAMBURGER, DRAWER_OPENED_SWIPE }) @Retention(RetentionPolicy.SOURCE) public @interface DrawerTrigger {} /** * Logs when DocumentsUI is started, and how. Call this when DocumentsUI first starts up. * Loading Loading @@ -286,6 +302,20 @@ public final class Metrics { logCount(context, COUNT_MULTI_WINDOW); } /** * 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 Loading
src/com/android/documentsui/NavigationView.java +1 −1 Original line number Diff line number Diff line Loading @@ -91,7 +91,7 @@ class NavigationView { private void onNavigationIconClicked() { if (mDrawer.isPresent()) { mDrawer.setOpen(true); mDrawer.setOpen(true, DrawerController.OPENED_HAMBURGER); } } Loading