Make Metrics.logKeyboardAction() method take @KeyboardAction type
instead of KeyEvent Change-Id: Ib9a19532612b679141b6d611e448247d3b0bab23 Fixing: b/27942360
This commit is contained in:
@@ -636,12 +636,12 @@ public abstract class BaseActivity extends Activity
|
||||
return true;
|
||||
}
|
||||
} 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.
|
||||
toggleNavDrawerFocus();
|
||||
return true;
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DEL) {
|
||||
Metrics.logKeyboardAction(this, keyCode);
|
||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_BACK);
|
||||
popDir();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -349,21 +349,21 @@ public class FilesActivity extends BaseActivity {
|
||||
case KeyEvent.KEYCODE_A:
|
||||
dir = getDirectoryFragment();
|
||||
if (dir != null) {
|
||||
Metrics.logKeyboardAction(this, keyCode);
|
||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_SELECT_ALL);
|
||||
dir.selectAllFiles();
|
||||
}
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_C:
|
||||
dir = getDirectoryFragment();
|
||||
if (dir != null) {
|
||||
Metrics.logKeyboardAction(this, keyCode);
|
||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_COPY);
|
||||
dir.copySelectedToClipboard();
|
||||
}
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_V:
|
||||
dir = getDirectoryFragment();
|
||||
if (dir != null) {
|
||||
Metrics.logKeyboardAction(this, keyCode);
|
||||
Metrics.logKeyboardAction(this, Metrics.ACTION_KEYBOARD_PASTE);
|
||||
dir.pasteFromClipboard();
|
||||
}
|
||||
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
|
||||
// list.
|
||||
// Do not use negative numbers or zero; clearcut only handles positive integers.
|
||||
private static final int ACTION_KEYBOARD_OTHER = 1;
|
||||
private static final int ACTION_KEYBOARD_PASTE = 2;
|
||||
private static final int ACTION_KEYBOARD_COPY = 3;
|
||||
private static final int ACTION_KEYBOARD_DELETE = 4;
|
||||
private static final int ACTION_KEYBOARD_SELECT_ALL = 5;
|
||||
private static final int ACTION_KEYBOARD_BACK = 6;
|
||||
private static final int ACTION_KEYBOARD_SWITCH_FOCUS = 7;
|
||||
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,
|
||||
@@ -525,31 +525,8 @@ public final class Metrics {
|
||||
* @param context
|
||||
* @param keyCode
|
||||
*/
|
||||
public static void logKeyboardAction(Context context, int keyCode) {
|
||||
@KeyboardAction int keyboardAction = ACTION_KEYBOARD_OTHER;
|
||||
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);
|
||||
public static void logKeyboardAction(Context context, @KeyboardAction int action) {
|
||||
logHistogram(context, COUNT_KEYBOARD_ACTION, action);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1339,7 +1339,7 @@ public class DirectoryFragment extends Fragment
|
||||
// This has to be handled here instead of in a keyboard shortcut, because
|
||||
// keyboard shortcuts all have to be modified with the 'Ctrl' key.
|
||||
if (mSelectionManager.hasSelection()) {
|
||||
Metrics.logKeyboardAction(getContext(), keyCode);
|
||||
Metrics.logKeyboardAction(getContext(), Metrics.ACTION_KEYBOARD_DELETE);
|
||||
deleteDocuments(mSelectionManager.getSelection());
|
||||
}
|
||||
// Always handle the key, even if there was nothing to delete. This is a
|
||||
|
||||
Reference in New Issue
Block a user