Merge "Consolidate user actions metrics into one histogram." into nyc-dev
am: 9870ad9
* commit '9870ad94ed4dd1a60e4122b94cd8b72bbb06ca24':
Consolidate user actions metrics into one histogram.
Change-Id: I7b1e75beaea25f632f7a9c8de33a388409b6c212
This commit is contained in:
@@ -257,7 +257,6 @@ public abstract class BaseActivity extends Activity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
Metrics.logMenuAction(this, item.getItemId());
|
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
@@ -279,6 +278,7 @@ public abstract class BaseActivity extends Activity
|
|||||||
case R.id.menu_sort_date:
|
case R.id.menu_sort_date:
|
||||||
setUserSortOrder(State.SORT_ORDER_LAST_MODIFIED);
|
setUserSortOrder(State.SORT_ORDER_LAST_MODIFIED);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_sort_size:
|
case R.id.menu_sort_size:
|
||||||
setUserSortOrder(State.SORT_ORDER_SIZE);
|
setUserSortOrder(State.SORT_ORDER_SIZE);
|
||||||
return true;
|
return true;
|
||||||
@@ -307,6 +307,8 @@ public abstract class BaseActivity extends Activity
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case R.id.menu_settings:
|
case R.id.menu_settings:
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_SETTINGS);
|
||||||
|
|
||||||
final RootInfo root = getCurrentRoot();
|
final RootInfo root = getCurrentRoot();
|
||||||
final Intent intent = new Intent(DocumentsContract.ACTION_DOCUMENT_ROOT_SETTINGS);
|
final Intent intent = new Intent(DocumentsContract.ACTION_DOCUMENT_ROOT_SETTINGS);
|
||||||
intent.setDataAndType(root.getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
|
intent.setDataAndType(root.getUri(), DocumentsContract.Root.MIME_TYPE_ITEM);
|
||||||
@@ -323,6 +325,8 @@ public abstract class BaseActivity extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showCreateDirectoryDialog() {
|
void showCreateDirectoryDialog() {
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_CREATE_DIR);
|
||||||
|
|
||||||
CreateDirectoryFragment.show(getFragmentManager());
|
CreateDirectoryFragment.show(getFragmentManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,13 +473,25 @@ public abstract class BaseActivity extends Activity
|
|||||||
"com.android.providers.downloads.documents", "downloads");
|
"com.android.providers.downloads.documents", "downloads");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set internal storage visible based on explicit user action.
|
||||||
|
*/
|
||||||
void setDisplayAdvancedDevices(boolean display) {
|
void setDisplayAdvancedDevices(boolean display) {
|
||||||
|
Metrics.logUserAction(this,
|
||||||
|
display ? Metrics.USER_ACTION_SHOW_ADVANCED : Metrics.USER_ACTION_HIDE_ADVANCED);
|
||||||
|
|
||||||
mState.showAdvanced = display;
|
mState.showAdvanced = display;
|
||||||
RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
|
RootsFragment.get(getFragmentManager()).onDisplayStateChanged();
|
||||||
invalidateOptionsMenu();
|
invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set file size visible based on explicit user action.
|
||||||
|
*/
|
||||||
void setDisplayFileSize(boolean display) {
|
void setDisplayFileSize(boolean display) {
|
||||||
|
Metrics.logUserAction(this,
|
||||||
|
display ? Metrics.USER_ACTION_SHOW_SIZE : Metrics.USER_ACTION_HIDE_SIZE);
|
||||||
|
|
||||||
LocalPreferences.setDisplayFileSize(this, display);
|
LocalPreferences.setDisplayFileSize(this, display);
|
||||||
mState.showSize = display;
|
mState.showSize = display;
|
||||||
DirectoryFragment dir = getDirectoryFragment();
|
DirectoryFragment dir = getDirectoryFragment();
|
||||||
@@ -489,6 +505,18 @@ public abstract class BaseActivity extends Activity
|
|||||||
* Set state sort order based on explicit user action.
|
* Set state sort order based on explicit user action.
|
||||||
*/
|
*/
|
||||||
void setUserSortOrder(int sortOrder) {
|
void setUserSortOrder(int sortOrder) {
|
||||||
|
switch(sortOrder) {
|
||||||
|
case State.SORT_ORDER_DISPLAY_NAME:
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_SORT_NAME);
|
||||||
|
break;
|
||||||
|
case State.SORT_ORDER_LAST_MODIFIED:
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_SORT_DATE);
|
||||||
|
break;
|
||||||
|
case State.SORT_ORDER_SIZE:
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_SORT_SIZE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
mState.userSortOrder = sortOrder;
|
mState.userSortOrder = sortOrder;
|
||||||
DirectoryFragment dir = getDirectoryFragment();
|
DirectoryFragment dir = getDirectoryFragment();
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
@@ -500,6 +528,12 @@ public abstract class BaseActivity extends Activity
|
|||||||
* Set mode based on explicit user action.
|
* Set mode based on explicit user action.
|
||||||
*/
|
*/
|
||||||
void setViewMode(@ViewMode int mode) {
|
void setViewMode(@ViewMode int mode) {
|
||||||
|
if (mode == State.MODE_GRID) {
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_GRID);
|
||||||
|
} else if (mode == State.MODE_LIST) {
|
||||||
|
Metrics.logUserAction(this, Metrics.USER_ACTION_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
LocalPreferences.setViewMode(this, getCurrentRoot(), mode);
|
LocalPreferences.setViewMode(this, getCurrentRoot(), mode);
|
||||||
mState.derivedMode = mode;
|
mState.derivedMode = mode;
|
||||||
|
|
||||||
@@ -621,12 +655,10 @@ public abstract class BaseActivity extends Activity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_TAB) {
|
} else if (keyCode == KeyEvent.KEYCODE_TAB) {
|
||||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_SWITCH_FOCUS);
|
|
||||||
// Tab toggles focus on the navigation drawer.
|
// Tab toggles focus on the navigation drawer.
|
||||||
toggleNavDrawerFocus();
|
toggleNavDrawerFocus();
|
||||||
return true;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
|
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
|
||||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_BACK);
|
|
||||||
popDir();
|
popDir();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,13 +228,12 @@ public class FilesActivity extends BaseActivity {
|
|||||||
default:
|
default:
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
Metrics.logMenuAction(this, item.getItemId());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewWindow() {
|
private void createNewWindow() {
|
||||||
Metrics.logMultiWindow(this);
|
Metrics.logUserAction(this, Metrics.USER_ACTION_NEW_WINDOW);
|
||||||
|
|
||||||
Intent intent = LauncherActivity.createLaunchIntent(this);
|
Intent intent = LauncherActivity.createLaunchIntent(this);
|
||||||
intent.putExtra(Shared.EXTRA_STACK, (Parcelable) mState.stack);
|
intent.putExtra(Shared.EXTRA_STACK, (Parcelable) mState.stack);
|
||||||
|
|
||||||
@@ -352,21 +351,18 @@ public class FilesActivity extends BaseActivity {
|
|||||||
case KeyEvent.KEYCODE_A:
|
case KeyEvent.KEYCODE_A:
|
||||||
dir = getDirectoryFragment();
|
dir = getDirectoryFragment();
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_SELECT_ALL);
|
|
||||||
dir.selectAllFiles();
|
dir.selectAllFiles();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case KeyEvent.KEYCODE_C:
|
case KeyEvent.KEYCODE_C:
|
||||||
dir = getDirectoryFragment();
|
dir = getDirectoryFragment();
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_COPY);
|
|
||||||
dir.copySelectedToClipboard();
|
dir.copySelectedToClipboard();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case KeyEvent.KEYCODE_V:
|
case KeyEvent.KEYCODE_V:
|
||||||
dir = getDirectoryFragment();
|
dir = getDirectoryFragment();
|
||||||
if (dir != null) {
|
if (dir != null) {
|
||||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_PASTE);
|
|
||||||
dir.pasteFromClipboard();
|
dir.pasteFromClipboard();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -62,16 +62,13 @@ public final class Metrics {
|
|||||||
private static final String COUNT_GET_CONTENT_MIME = "docsui_get_content_mime";
|
private static final String COUNT_GET_CONTENT_MIME = "docsui_get_content_mime";
|
||||||
private static final String COUNT_BROWSE_ROOT = "docsui_browse_root";
|
private static final String COUNT_BROWSE_ROOT = "docsui_browse_root";
|
||||||
@Deprecated private static final String COUNT_MANAGE_ROOT = "docsui_manage_root";
|
@Deprecated private static final String COUNT_MANAGE_ROOT = "docsui_manage_root";
|
||||||
private static final String COUNT_MULTI_WINDOW = "docsui_multi_window";
|
@Deprecated private static final String COUNT_MULTI_WINDOW = "docsui_multi_window";
|
||||||
private static final String COUNT_FILEOP_SYSTEM = "docsui_fileop_system";
|
private static final String COUNT_FILEOP_SYSTEM = "docsui_fileop_system";
|
||||||
private static final String COUNT_FILEOP_EXTERNAL = "docsui_fileop_external";
|
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_FILEOP_CANCELED = "docsui_fileop_canceled";
|
||||||
private static final String COUNT_STARTUP_MS = "docsui_startup_ms";
|
private static final String COUNT_STARTUP_MS = "docsui_startup_ms";
|
||||||
private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened";
|
private static final String COUNT_DRAWER_OPENED = "docsui_drawer_opened";
|
||||||
private static final String COUNT_DRAG_N_DROP = "docsui_drag_n_drop";
|
private static final String COUNT_USER_ACTION = "docsui_menu_action";
|
||||||
private static final String COUNT_SEARCH = "docsui_search";
|
|
||||||
private static final String COUNT_MENU_ACTION = "docsui_menu_action";
|
|
||||||
private static final String COUNT_KEYBOARD_ACTION = "docsui_keyboard_action";
|
|
||||||
|
|
||||||
// Indices for bucketing roots in the roots histogram. "Other" is the catch-all index for any
|
// 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
|
// root that is not explicitly recognized by the Metrics code (see {@link
|
||||||
@@ -215,54 +212,67 @@ public final class Metrics {
|
|||||||
public @interface Provider {}
|
public @interface Provider {}
|
||||||
|
|
||||||
|
|
||||||
// Codes representing different menu actions. These are used for bucketing stats in the
|
// Codes representing different user actions. These are used for bucketing stats in the
|
||||||
// COUNT_MENU_ACTION histogram.
|
// COUNT_USER_ACTION histogram.
|
||||||
// Both regular toolbar menu and action mode menu operations are included.
|
// The historgram includes action triggered from menu or invoked by keyboard shortcut.
|
||||||
// Do not change or rearrange these values, that will break historical data. Only add to the
|
// Do not change or rearrange these values, that will break historical data. Only add to the
|
||||||
// list.
|
// list.
|
||||||
// Do not use negative numbers or zero; clearcut only handles positive integers.
|
// Do not use negative numbers or zero; clearcut only handles positive integers.
|
||||||
private static final int ACTION_MENU_OTHER = 1;
|
public static final int USER_ACTION_OTHER = 1;
|
||||||
private static final int ACTION_MENU_GRID = 2;
|
public static final int USER_ACTION_GRID = 2;
|
||||||
private static final int ACTION_MENU_LIST = 3;
|
public static final int USER_ACTION_LIST = 3;
|
||||||
private static final int ACTION_MENU_SORT = 4;
|
public static final int USER_ACTION_SORT_NAME = 4;
|
||||||
private static final int ACTION_MENU_SORT_NAME = 5;
|
public static final int USER_ACTION_SORT_DATE = 5;
|
||||||
private static final int ACTION_MENU_SORT_DATE = 6;
|
public static final int USER_ACTION_SORT_SIZE = 6;
|
||||||
private static final int ACTION_MENU_SORT_SIZE = 7;
|
public static final int USER_ACTION_SEARCH = 7;
|
||||||
private static final int ACTION_MENU_SEARCH = 8;
|
public static final int USER_ACTION_SHOW_SIZE = 8;
|
||||||
private static final int ACTION_MENU_SHOW_SIZE = 9;
|
public static final int USER_ACTION_HIDE_SIZE = 9;
|
||||||
private static final int ACTION_MENU_SETTINGS = 10;
|
public static final int USER_ACTION_SETTINGS = 10;
|
||||||
private static final int ACTION_MENU_COPY_TO = 11;
|
public static final int USER_ACTION_COPY_TO = 11;
|
||||||
private static final int ACTION_MENU_MOVE_TO = 12;
|
public static final int USER_ACTION_MOVE_TO = 12;
|
||||||
private static final int ACTION_MENU_DELETE = 13;
|
public static final int USER_ACTION_DELETE = 13;
|
||||||
private static final int ACTION_MENU_RENAME = 14;
|
public static final int USER_ACTION_RENAME = 14;
|
||||||
private static final int ACTION_MENU_CREATE_DIR = 15;
|
public static final int USER_ACTION_CREATE_DIR = 15;
|
||||||
private static final int ACTION_MENU_SELECT_ALL = 16;
|
public static final int USER_ACTION_SELECT_ALL = 16;
|
||||||
private static final int ACTION_MENU_SHARE = 17;
|
public static final int USER_ACTION_SHARE = 17;
|
||||||
private static final int ACTION_MENU_OPEN = 18;
|
public static final int USER_ACTION_OPEN = 18;
|
||||||
private static final int ACTION_MENU_ADVANCED = 19;
|
public static final int USER_ACTION_SHOW_ADVANCED = 19;
|
||||||
|
public static final int USER_ACTION_HIDE_ADVANCED = 20;
|
||||||
|
public static final int USER_ACTION_NEW_WINDOW = 21;
|
||||||
|
public static final int USER_ACTION_PASTE_CLIPBOARD = 22;
|
||||||
|
public static final int USER_ACTION_COPY_CLIPBOARD = 23;
|
||||||
|
public static final int USER_ACTION_DRAG_N_DROP = 24;
|
||||||
|
public static final int USER_ACTION_DRAG_N_DROP_MULTI_WINDOW = 25;
|
||||||
|
|
||||||
@IntDef(flag = false, value = {
|
@IntDef(flag = false, value = {
|
||||||
ACTION_MENU_OTHER,
|
USER_ACTION_OTHER,
|
||||||
ACTION_MENU_GRID,
|
USER_ACTION_GRID,
|
||||||
ACTION_MENU_LIST,
|
USER_ACTION_LIST,
|
||||||
ACTION_MENU_SORT,
|
USER_ACTION_SORT_NAME,
|
||||||
ACTION_MENU_SORT_NAME,
|
USER_ACTION_SORT_DATE,
|
||||||
ACTION_MENU_SORT_DATE,
|
USER_ACTION_SORT_SIZE,
|
||||||
ACTION_MENU_SORT_SIZE,
|
USER_ACTION_SEARCH,
|
||||||
ACTION_MENU_SHOW_SIZE,
|
USER_ACTION_SHOW_SIZE,
|
||||||
ACTION_MENU_SETTINGS,
|
USER_ACTION_HIDE_SIZE,
|
||||||
ACTION_MENU_COPY_TO,
|
USER_ACTION_SETTINGS,
|
||||||
ACTION_MENU_MOVE_TO,
|
USER_ACTION_COPY_TO,
|
||||||
ACTION_MENU_DELETE,
|
USER_ACTION_MOVE_TO,
|
||||||
ACTION_MENU_RENAME,
|
USER_ACTION_DELETE,
|
||||||
ACTION_MENU_CREATE_DIR,
|
USER_ACTION_RENAME,
|
||||||
ACTION_MENU_SELECT_ALL,
|
USER_ACTION_CREATE_DIR,
|
||||||
ACTION_MENU_SHARE,
|
USER_ACTION_SELECT_ALL,
|
||||||
ACTION_MENU_OPEN,
|
USER_ACTION_SHARE,
|
||||||
ACTION_MENU_ADVANCED
|
USER_ACTION_OPEN,
|
||||||
|
USER_ACTION_SHOW_ADVANCED,
|
||||||
|
USER_ACTION_HIDE_ADVANCED,
|
||||||
|
USER_ACTION_NEW_WINDOW,
|
||||||
|
USER_ACTION_PASTE_CLIPBOARD,
|
||||||
|
USER_ACTION_COPY_CLIPBOARD,
|
||||||
|
USER_ACTION_DRAG_N_DROP,
|
||||||
|
USER_ACTION_DRAG_N_DROP_MULTI_WINDOW
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface MenuAction {}
|
public @interface UserAction {}
|
||||||
|
|
||||||
// Codes representing different menu actions. These are used for bucketing stats in the
|
// Codes representing different menu actions. These are used for bucketing stats in the
|
||||||
// COUNT_MENU_ACTION histogram.
|
// COUNT_MENU_ACTION histogram.
|
||||||
@@ -291,31 +301,6 @@ public final class Metrics {
|
|||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface MetricsAction {}
|
public @interface MetricsAction {}
|
||||||
|
|
||||||
// Codes representing different keyboard shortcut triggered actions. These are used for
|
|
||||||
// bucketing stats in the COUNT_KEYBOARD_ACTION 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.
|
|
||||||
public static final int ACTION_KEYBOARD_OTHER = 1;
|
|
||||||
public static final int ACTION_KEYBOARD_PASTE = 2;
|
|
||||||
public static final int ACTION_KEYBOARD_COPY = 3;
|
|
||||||
public static final int ACTION_KEYBOARD_DELETE = 4;
|
|
||||||
public static final int ACTION_KEYBOARD_SELECT_ALL = 5;
|
|
||||||
public static final int ACTION_KEYBOARD_BACK = 6;
|
|
||||||
public static final int ACTION_KEYBOARD_SWITCH_FOCUS = 7;
|
|
||||||
|
|
||||||
@IntDef(flag = false, value = {
|
|
||||||
ACTION_KEYBOARD_OTHER,
|
|
||||||
ACTION_KEYBOARD_PASTE,
|
|
||||||
ACTION_KEYBOARD_COPY,
|
|
||||||
ACTION_KEYBOARD_DELETE,
|
|
||||||
ACTION_KEYBOARD_SELECT_ALL,
|
|
||||||
ACTION_KEYBOARD_BACK,
|
|
||||||
ACTION_KEYBOARD_SWITCH_FOCUS
|
|
||||||
})
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
public @interface KeyboardAction {}
|
|
||||||
|
|
||||||
// Codes representing different actions to open the drawer. They are used for bucketing stats in
|
// Codes representing different actions to open the drawer. They are used for bucketing stats in
|
||||||
// the COUNT_DRAWER_OPENED histogram.
|
// the COUNT_DRAWER_OPENED histogram.
|
||||||
// Do not change or rearrange these values, that will break historical data. Only add to the
|
// Do not change or rearrange these values, that will break historical data. Only add to the
|
||||||
@@ -381,15 +366,6 @@ public final class Metrics {
|
|||||||
logHistogram(context, COUNT_ROOT_VISITED, sanitizeRoot(info));
|
logHistogram(context, COUNT_ROOT_VISITED, sanitizeRoot(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a multi-window start. Call this when the user spawns a new DocumentsUI window.
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
*/
|
|
||||||
public static void logMultiWindow(Context context) {
|
|
||||||
logCount(context, COUNT_MULTI_WINDOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a drawer opened event. Call this when the user opens drawer by swipe or by clicking the
|
* Logs a drawer opened event. Call this when the user opens drawer by swipe or by clicking the
|
||||||
* hamburger icon.
|
* hamburger icon.
|
||||||
@@ -496,7 +472,7 @@ public final class Metrics {
|
|||||||
* @param context
|
* @param context
|
||||||
*/
|
*/
|
||||||
public static void logCreateDirError(Context context) {
|
public static void logCreateDirError(Context context) {
|
||||||
logHistogram(context, COUNT_FILEOP_SYSTEM, FILEOP_CREATE_DIR);
|
logHistogram(context, COUNT_FILEOP_SYSTEM, FILEOP_CREATE_DIR_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -519,16 +495,6 @@ public final class Metrics {
|
|||||||
logHistogram(context, COUNT_FILEOP_CANCELED, toMetricsOpType(operationType));
|
logHistogram(context, COUNT_FILEOP_CANCELED, toMetricsOpType(operationType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs keyboard shortcut actions. Since keyboard shortcuts have their corresponding menu items,
|
|
||||||
* they are identified by menu item resource id for convenience.
|
|
||||||
* @param context
|
|
||||||
* @param keyCode
|
|
||||||
*/
|
|
||||||
public static void logKeyboardAction(Context context, @KeyboardAction int action) {
|
|
||||||
logHistogram(context, COUNT_KEYBOARD_ACTION, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs startup time in milliseconds.
|
* Logs startup time in milliseconds.
|
||||||
* @param context
|
* @param context
|
||||||
@@ -538,25 +504,6 @@ public final class Metrics {
|
|||||||
logHistogram(context, COUNT_STARTUP_MS, startupMs);
|
logHistogram(context, COUNT_STARTUP_MS, startupMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a drag and drop action. Call this when the user drops the content triggering copy.
|
|
||||||
* operation.
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
*/
|
|
||||||
public static void logDragNDrop(Context context) {
|
|
||||||
logCount(context, COUNT_DRAG_N_DROP);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Logs a search. Call this when the search operation is finished.
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
*/
|
|
||||||
public static void logSearch(Context context) {
|
|
||||||
logCount(context, COUNT_SEARCH);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void logInterProviderFileOps(
|
private static void logInterProviderFileOps(
|
||||||
Context context,
|
Context context,
|
||||||
String histogram,
|
String histogram,
|
||||||
@@ -677,71 +624,12 @@ public final class Metrics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs menu action that was selected by user.
|
* Logs the action that was started by user.
|
||||||
* @param context
|
* @param context
|
||||||
* @param id Resource id of the menu item.
|
* @param userAction
|
||||||
*/
|
*/
|
||||||
public static void logMenuAction(Context context, int id) {
|
public static void logUserAction(Context context, @UserAction int userAction) {
|
||||||
@MenuAction int menuAction = ACTION_MENU_OTHER;
|
logHistogram(context, COUNT_USER_ACTION, userAction);
|
||||||
switch (id) {
|
|
||||||
case R.id.menu_grid:
|
|
||||||
menuAction = ACTION_MENU_GRID;
|
|
||||||
break;
|
|
||||||
case R.id.menu_list:
|
|
||||||
menuAction = ACTION_MENU_LIST;
|
|
||||||
break;
|
|
||||||
case R.id.menu_sort:
|
|
||||||
menuAction = ACTION_MENU_SORT;
|
|
||||||
break;
|
|
||||||
case R.id.menu_sort_name:
|
|
||||||
menuAction = ACTION_MENU_SORT_NAME;
|
|
||||||
break;
|
|
||||||
case R.id.menu_sort_date:
|
|
||||||
menuAction = ACTION_MENU_SORT_DATE;
|
|
||||||
break;
|
|
||||||
case R.id.menu_sort_size:
|
|
||||||
menuAction = ACTION_MENU_SORT_SIZE;
|
|
||||||
break;
|
|
||||||
case R.id.menu_search:
|
|
||||||
menuAction = ACTION_MENU_SEARCH;
|
|
||||||
break;
|
|
||||||
case R.id.menu_file_size:
|
|
||||||
menuAction = ACTION_MENU_SHOW_SIZE;
|
|
||||||
break;
|
|
||||||
case R.id.menu_settings:
|
|
||||||
menuAction = ACTION_MENU_SETTINGS;
|
|
||||||
break;
|
|
||||||
case R.id.menu_copy_to:
|
|
||||||
menuAction = ACTION_MENU_COPY_TO;
|
|
||||||
break;
|
|
||||||
case R.id.menu_move_to:
|
|
||||||
menuAction = ACTION_MENU_MOVE_TO;
|
|
||||||
break;
|
|
||||||
case R.id.menu_delete:
|
|
||||||
menuAction = ACTION_MENU_DELETE;
|
|
||||||
break;
|
|
||||||
case R.id.menu_rename:
|
|
||||||
menuAction = ACTION_MENU_RENAME;
|
|
||||||
break;
|
|
||||||
case R.id.menu_create_dir:
|
|
||||||
menuAction = ACTION_MENU_CREATE_DIR;
|
|
||||||
break;
|
|
||||||
case R.id.menu_select_all:
|
|
||||||
menuAction = ACTION_MENU_SELECT_ALL;
|
|
||||||
break;
|
|
||||||
case R.id.menu_share:
|
|
||||||
menuAction = ACTION_MENU_SHARE;
|
|
||||||
break;
|
|
||||||
case R.id.menu_open:
|
|
||||||
menuAction = ACTION_MENU_OPEN;
|
|
||||||
break;
|
|
||||||
case R.id.menu_advanced:
|
|
||||||
menuAction = ACTION_MENU_ADVANCED;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
logHistogram(context, COUNT_MENU_ACTION, menuAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -185,9 +185,6 @@ final class SearchViewManager implements
|
|||||||
if(mFullBar) {
|
if(mFullBar) {
|
||||||
Menu menu = mActionBar.getMenu();
|
Menu menu = mActionBar.getMenu();
|
||||||
menu.setGroupVisible(R.id.group_hide_when_searching, false);
|
menu.setGroupVisible(R.id.group_hide_when_searching, false);
|
||||||
} else {
|
|
||||||
// If search in full-bar mode it will be logged in FilesActivity#onOptionsItemSelected
|
|
||||||
Metrics.logMenuAction(mActionBar.getContext(), R.id.menu_search);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -605,8 +605,6 @@ public class DirectoryFragment extends Fragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||||
Metrics.logMenuAction(getContext(), item.getItemId());
|
|
||||||
|
|
||||||
Selection selection = mSelectionManager.getSelection(new Selection());
|
Selection selection = mSelectionManager.getSelection(new Selection());
|
||||||
|
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
@@ -674,6 +672,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void openDocuments(final Selection selected) {
|
private void openDocuments(final Selection selected) {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_OPEN);
|
||||||
|
|
||||||
new GetDocumentsTask() {
|
new GetDocumentsTask() {
|
||||||
@Override
|
@Override
|
||||||
void onDocumentsReady(List<DocumentInfo> docs) {
|
void onDocumentsReady(List<DocumentInfo> docs) {
|
||||||
@@ -684,6 +684,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void shareDocuments(final Selection selected) {
|
private void shareDocuments(final Selection selected) {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_SHARE);
|
||||||
|
|
||||||
new GetDocumentsTask() {
|
new GetDocumentsTask() {
|
||||||
@Override
|
@Override
|
||||||
void onDocumentsReady(List<DocumentInfo> docs) {
|
void onDocumentsReady(List<DocumentInfo> docs) {
|
||||||
@@ -765,6 +767,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void deleteDocuments(final Selection selected) {
|
private void deleteDocuments(final Selection selected) {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_DELETE);
|
||||||
|
|
||||||
assert(!selected.isEmpty());
|
assert(!selected.isEmpty());
|
||||||
|
|
||||||
final DocumentInfo srcParent = getDisplayState().stack.peek();
|
final DocumentInfo srcParent = getDisplayState().stack.peek();
|
||||||
@@ -815,6 +819,12 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void transferDocuments(final Selection selected, final @OpType int mode) {
|
private void transferDocuments(final Selection selected, final @OpType int mode) {
|
||||||
|
if(mode == FileOperationService.OPERATION_COPY) {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_COPY_TO);
|
||||||
|
} else if (mode == FileOperationService.OPERATION_MOVE) {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_MOVE_TO);
|
||||||
|
}
|
||||||
|
|
||||||
// Pop up a dialog to pick a destination. This is inadequate but works for now.
|
// Pop up a dialog to pick a destination. This is inadequate but works for now.
|
||||||
// TODO: Implement a picker that is to spec.
|
// TODO: Implement a picker that is to spec.
|
||||||
final Intent intent = new Intent(
|
final Intent intent = new Intent(
|
||||||
@@ -861,6 +871,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renameDocuments(Selection selected) {
|
private void renameDocuments(Selection selected) {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_RENAME);
|
||||||
|
|
||||||
// Batch renaming not supported
|
// Batch renaming not supported
|
||||||
// Rename option is only available in menu when 1 document selected
|
// Rename option is only available in menu when 1 document selected
|
||||||
assert(selected.size() == 1);
|
assert(selected.size() == 1);
|
||||||
@@ -1020,6 +1032,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void copySelectedToClipboard() {
|
public void copySelectedToClipboard() {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_COPY_CLIPBOARD);
|
||||||
|
|
||||||
Selection selection = mSelectionManager.getSelection(new Selection());
|
Selection selection = mSelectionManager.getSelection(new Selection());
|
||||||
if (!selection.isEmpty()) {
|
if (!selection.isEmpty()) {
|
||||||
copySelectionToClipboard(selection);
|
copySelectionToClipboard(selection);
|
||||||
@@ -1043,6 +1057,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void pasteFromClipboard() {
|
public void pasteFromClipboard() {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_PASTE_CLIPBOARD);
|
||||||
|
|
||||||
copyFromClipboard();
|
copyFromClipboard();
|
||||||
getActivity().invalidateOptionsMenu();
|
getActivity().invalidateOptionsMenu();
|
||||||
}
|
}
|
||||||
@@ -1073,6 +1089,8 @@ public class DirectoryFragment extends Fragment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void selectAllFiles() {
|
public void selectAllFiles() {
|
||||||
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_SELECT_ALL);
|
||||||
|
|
||||||
// Exclude disabled files
|
// Exclude disabled files
|
||||||
List<String> enabled = new ArrayList<String>();
|
List<String> enabled = new ArrayList<String>();
|
||||||
for (String id : mAdapter.getModelIds()) {
|
for (String id : mAdapter.getModelIds()) {
|
||||||
@@ -1147,7 +1165,14 @@ public class DirectoryFragment extends Fragment
|
|||||||
if (Objects.equals(src, dst)) {
|
if (Objects.equals(src, dst)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Metrics.logDragNDrop(getContext());
|
// Recognize multi-window drag and drop based on the fact that localState is not
|
||||||
|
// carried between processes. It will stop working when the localsState behavior
|
||||||
|
// is changed. The info about window should be passed in the localState then.
|
||||||
|
// The localState could also be null for copying from Recents in single window
|
||||||
|
// mode, but Recents doesn't offer this functionality (no directories).
|
||||||
|
Metrics.logUserAction(getContext(),
|
||||||
|
src == null ? Metrics.USER_ACTION_DRAG_N_DROP_MULTI_WINDOW
|
||||||
|
: Metrics.USER_ACTION_DRAG_N_DROP);
|
||||||
copyFromClipData(event.getClipData(), dst);
|
copyFromClipData(event.getClipData(), dst);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1387,7 +1412,6 @@ public class DirectoryFragment extends Fragment
|
|||||||
// This has to be handled here instead of in a keyboard shortcut, because
|
// This has to be handled here instead of in a keyboard shortcut, because
|
||||||
// keyboard shortcuts all have to be modified with the 'Ctrl' key.
|
// keyboard shortcuts all have to be modified with the 'Ctrl' key.
|
||||||
if (mSelectionManager.hasSelection()) {
|
if (mSelectionManager.hasSelection()) {
|
||||||
Metrics.logKeyboardAction(getContext(), Metrics.ACTION_KEYBOARD_DELETE);
|
|
||||||
deleteDocuments(mSelectionManager.getSelection());
|
deleteDocuments(mSelectionManager.getSelection());
|
||||||
}
|
}
|
||||||
// Always handle the key, even if there was nothing to delete. This is a
|
// Always handle the key, even if there was nothing to delete. This is a
|
||||||
@@ -1674,8 +1698,9 @@ public class DirectoryFragment extends Fragment
|
|||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) {
|
public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) {
|
||||||
if (!isAdded()) return;
|
if (!isAdded()) return;
|
||||||
|
|
||||||
if (mSearchMode) {
|
if (mSearchMode) {
|
||||||
Metrics.logSearch(getContext());
|
Metrics.logUserAction(getContext(), Metrics.USER_ACTION_SEARCH);
|
||||||
}
|
}
|
||||||
|
|
||||||
State state = getDisplayState();
|
State state = getDisplayState();
|
||||||
|
|||||||
Reference in New Issue
Block a user