Merge "Make Metrics.logKeyboardAction() method take @KeyboardAction type instead of KeyEvent" into nyc-dev
This commit is contained in:
@@ -636,12 +636,12 @@ 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, keyCode);
|
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, keyCode);
|
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_BACK);
|
||||||
popDir();
|
popDir();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,21 +349,21 @@ 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, keyCode);
|
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, keyCode);
|
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, keyCode);
|
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_PASTE);
|
||||||
dir.pasteFromClipboard();
|
dir.pasteFromClipboard();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -296,13 +296,13 @@ public final class Metrics {
|
|||||||
// 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_KEYBOARD_OTHER = 1;
|
public static final int ACTION_KEYBOARD_OTHER = 1;
|
||||||
private static final int ACTION_KEYBOARD_PASTE = 2;
|
public static final int ACTION_KEYBOARD_PASTE = 2;
|
||||||
private static final int ACTION_KEYBOARD_COPY = 3;
|
public static final int ACTION_KEYBOARD_COPY = 3;
|
||||||
private static final int ACTION_KEYBOARD_DELETE = 4;
|
public static final int ACTION_KEYBOARD_DELETE = 4;
|
||||||
private static final int ACTION_KEYBOARD_SELECT_ALL = 5;
|
public static final int ACTION_KEYBOARD_SELECT_ALL = 5;
|
||||||
private static final int ACTION_KEYBOARD_BACK = 6;
|
public static final int ACTION_KEYBOARD_BACK = 6;
|
||||||
private static final int ACTION_KEYBOARD_SWITCH_FOCUS = 7;
|
public static final int ACTION_KEYBOARD_SWITCH_FOCUS = 7;
|
||||||
|
|
||||||
@IntDef(flag = false, value = {
|
@IntDef(flag = false, value = {
|
||||||
ACTION_KEYBOARD_OTHER,
|
ACTION_KEYBOARD_OTHER,
|
||||||
@@ -525,31 +525,8 @@ public final class Metrics {
|
|||||||
* @param context
|
* @param context
|
||||||
* @param keyCode
|
* @param keyCode
|
||||||
*/
|
*/
|
||||||
public static void logKeyboardAction(Context context, int keyCode) {
|
public static void logKeyboardAction(Context context, @KeyboardAction int action) {
|
||||||
@KeyboardAction int keyboardAction = ACTION_KEYBOARD_OTHER;
|
logHistogram(context, COUNT_KEYBOARD_ACTION, action);
|
||||||
switch (keyCode) {
|
|
||||||
case KeyEvent.KEYCODE_V:
|
|
||||||
keyboardAction = ACTION_KEYBOARD_PASTE;
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEYCODE_C:
|
|
||||||
keyboardAction = ACTION_KEYBOARD_COPY;
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEYCODE_FORWARD_DEL:
|
|
||||||
keyboardAction = ACTION_KEYBOARD_DELETE;
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEYCODE_A:
|
|
||||||
keyboardAction = ACTION_KEYBOARD_SELECT_ALL;
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEYCODE_DEL:
|
|
||||||
keyboardAction = ACTION_KEYBOARD_BACK;
|
|
||||||
break;
|
|
||||||
case KeyEvent.KEYCODE_TAB:
|
|
||||||
keyboardAction = ACTION_KEYBOARD_SWITCH_FOCUS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
logHistogram(context, COUNT_KEYBOARD_ACTION, keyboardAction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1339,7 +1339,7 @@ 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(), keyCode);
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user