Skip to content

Commit

Permalink
Add usage stats for mushroom.
Browse files Browse the repository at this point in the history
Note that usage stats is never be enabled in OSS build.
Hence no behavior change should occur.

BUG=none
TEST=unittest
  • Loading branch information
sumita12 authored and yukawa committed May 2, 2015
1 parent b64a7de commit a51ccee
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 7 deletions.
Expand Up @@ -44,10 +44,13 @@
*/
class MozcMenuDialogListenerImpl implements MenuDialogListener {
private final InputMethodService inputMethodService;
private final ViewEventListener eventListener;
private boolean showInputMethodPicker = false;

MozcMenuDialogListenerImpl(InputMethodService inputMethodService) {
MozcMenuDialogListenerImpl(
InputMethodService inputMethodService, ViewEventListener eventListener) {
this.inputMethodService = Preconditions.checkNotNull(inputMethodService);
this.eventListener = Preconditions.checkNotNull(eventListener);
}

@Override
Expand Down Expand Up @@ -96,11 +99,11 @@ public void onShowMushroomSelectionDialogSelected(Context context) {
inputConnection.setComposingText("", MozcUtil.CURSOR_POSITION_TAIL);
}

eventListener.onShowMushroomSelectionDialog();

// Launch the activity.
Intent intent = MushroomUtil.createMushroomSelectionActivityLaunchingIntent(
context, inputMethodService.getCurrentInputEditorInfo().fieldId, composingText);
context.startActivity(intent);

// TODO(hidehiko): Do we need to logging?
}
}
Expand Up @@ -383,6 +383,11 @@ public void onUpdateKeyboardLayoutAdjustment(
.putString(key, layoutAdjustment.toString())
.apply();
}

@Override
public void onShowMushroomSelectionDialog() {
sessionExecutor.sendUsageStatsEvent(UsageStatsEvent.MUSHROOM_SELECTION_DIALOG_OPEN_EVENT);
}
}

/**
Expand Down Expand Up @@ -754,7 +759,7 @@ private void prepareOnce(ViewEventListener eventListener,
eventListener,
symbolHistoryStorage,
imeSwitcher,
new MozcMenuDialogListenerImpl(this));
new MozcMenuDialogListenerImpl(this, eventListener));
}

// Setup FeedbackManager.
Expand Down
Expand Up @@ -154,4 +154,9 @@ public void onUpdateKeyboardLayoutAdjustment(
ViewManagerInterface.LayoutAdjustment layoutAdjustment) {
delegated.onUpdateKeyboardLayoutAdjustment(layoutAdjustment);
}

@Override
public void onShowMushroomSelectionDialog() {
delegated.onShowMushroomSelectionDialog();
}
}
Expand Up @@ -147,4 +147,7 @@ public void onSymbolCandidateSelected(SymbolMajorCategory majorCategory, String
*/
public void onUpdateKeyboardLayoutAdjustment(
ViewManagerInterface.LayoutAdjustment layoutAdjustment);

/** Called when the mushroom selection dialog is shown. */
public void onShowMushroomSelectionDialog();
}
Expand Up @@ -59,14 +59,16 @@
public class MozcMenuDialogListenerImplTest extends InstrumentationTestCaseWithMock {
private Context context;
private InputMethodService inputMethodService;
private ViewEventListener eventListener;
private MenuDialogListener listener;

@Override
protected void setUp() throws Exception {
super.setUp();
context = createMock(MockContext.class);
inputMethodService = createMock(InputMethodService.class);
listener = new MozcMenuDialogListenerImpl(inputMethodService);
eventListener = createMock(ViewEventListener.class);
listener = new MozcMenuDialogListenerImpl(inputMethodService, eventListener);
}

@Override
Expand All @@ -75,6 +77,7 @@ protected void tearDown() throws Exception {
MozcUtil.cancelShowInputMethodPicker(context);

listener = null;
eventListener = null;
inputMethodService = null;
context = null;
super.tearDown();
Expand Down Expand Up @@ -166,6 +169,7 @@ public void testShowMushroomSelectionDialogSelected() {
editorInfo.fieldId = 10;
expect(inputMethodService.getCurrentInputEditorInfo()).andStubReturn(editorInfo);
expect(context.getPackageName()).andStubReturn("org.mozc.android.inputmethod.japanese");
eventListener.onShowMushroomSelectionDialog();
Capture<Intent> intentCapture = new Capture<Intent>();
context.startActivity(capture(intentCapture));
replayAll();
Expand Down
1 change: 1 addition & 0 deletions src/data/usage_stats/stats.def
Expand Up @@ -541,6 +541,7 @@ SubmittedCandidateRowGE10
# The count of the fold/expand keyboard event.
KeyboardFoldEvent
KeyboardExpandEvent
MushroomSelectionDialogOpen

# for windows

Expand Down
2 changes: 1 addition & 1 deletion src/mozc_version_template.txt
@@ -1,6 +1,6 @@
MAJOR=2
MINOR=17
BUILD=2089
BUILD=2090
REVISION=102
# NACL_DICTIONARY_VERSION is the target version of the system dictionary to be
# downloaded by NaCl Mozc.
Expand Down
1 change: 1 addition & 0 deletions src/session/commands.proto
Expand Up @@ -481,6 +481,7 @@ message SessionCommand {
SUBMITTED_CANDIDATE_ROW_GE10 = 19;
KEYBOARD_FOLD_EVENT = 20;
KEYBOARD_EXPAND_EVENT = 21;
MUSHROOM_SELECTION_DIALOG_OPEN_EVENT = 22;
}
optional UsageStatsEvent usage_stats_event = 7;
optional int32 usage_stats_event_int_value = 9;
Expand Down
5 changes: 4 additions & 1 deletion src/session/session_usage_observer.cc
Expand Up @@ -367,8 +367,11 @@ void SessionUsageObserver::UpdateClientSideStats(const commands::Input &input,
case commands::SessionCommand::KEYBOARD_EXPAND_EVENT:
UsageStats::IncrementCount("KeyboardExpandEvent");
break;
case commands::SessionCommand::MUSHROOM_SELECTION_DIALOG_OPEN_EVENT:
UsageStats::IncrementCount("MushroomSelectionDialogOpen");
break;
default:
LOG(WARNING) << "client side usage stats event has invalid category";
LOG(DFATAL) << "client side usage stats event has invalid category";
break;
}
}
Expand Down

0 comments on commit a51ccee

Please sign in to comment.