Skip to content

Commit e9a9dbe

Browse files
Gilles DebunneAndroid (Google) Code Review
authored andcommitted
Merge "The back key stops selection mode in extracted text mode."
2 parents d61a3a1 + 34703b6 commit e9a9dbe

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

core/java/android/inputmethodservice/ExtractEditLayout.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
package android.inputmethodservice;
1818

19-
import com.android.internal.view.menu.MenuBuilder;
20-
import com.android.internal.view.menu.MenuPopupHelper;
21-
2219
import android.content.Context;
2320
import android.util.AttributeSet;
2421
import android.view.ActionMode;
@@ -29,6 +26,9 @@
2926
import android.widget.Button;
3027
import android.widget.LinearLayout;
3128

29+
import com.android.internal.view.menu.MenuBuilder;
30+
import com.android.internal.view.menu.MenuPopupHelper;
31+
3232
/**
3333
* ExtractEditLayout provides an ActionMode presentation for the
3434
* limited screen real estate in extract mode.
@@ -61,6 +61,22 @@ public ActionMode startActionModeForChild(View sourceView, ActionMode.Callback c
6161
return null;
6262
}
6363

64+
/**
65+
* @return true if an action mode is currently active.
66+
*/
67+
public boolean isActionModeStarted() {
68+
return mActionMode != null;
69+
}
70+
71+
/**
72+
* Finishes a possibly started action mode.
73+
*/
74+
public void finishActionMode() {
75+
if (mActionMode != null) {
76+
mActionMode.finish();
77+
}
78+
}
79+
6480
@Override
6581
public void onFinishInflate() {
6682
super.onFinishInflate();
@@ -92,7 +108,7 @@ public void setTitle(CharSequence title) {
92108

93109
@Override
94110
public void setTitle(int resId) {
95-
// Title will nor be shown.
111+
// Title will not be shown.
96112
}
97113

98114
@Override

core/java/android/inputmethodservice/InputMethodService.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ public void setTheme(int theme) {
637637
* configuration change happens.
638638
*/
639639
public void onInitializeInterface() {
640+
// Intentionally empty
640641
}
641642

642643
void initialize() {
@@ -876,8 +877,7 @@ public void updateFullscreenMode() {
876877
}
877878

878879
if (changed) {
879-
onConfigureWindow(mWindow.getWindow(), isFullscreen,
880-
!mShowInputRequested);
880+
onConfigureWindow(mWindow.getWindow(), isFullscreen, !mShowInputRequested);
881881
mLastShowInputRequested = mShowInputRequested;
882882
}
883883
}
@@ -935,7 +935,7 @@ public boolean onEvaluateFullscreenMode() {
935935
}
936936
return true;
937937
}
938-
938+
939939
/**
940940
* Controls the visibility of the extracted text area. This only applies
941941
* when the input method is in fullscreen mode, and thus showing extracted
@@ -1242,6 +1242,7 @@ public View onCreateInputView() {
12421242
* same text field as before.
12431243
*/
12441244
public void onStartInputView(EditorInfo info, boolean restarting) {
1245+
// Intentionally empty
12451246
}
12461247

12471248
/**
@@ -1286,6 +1287,7 @@ public void onFinishInputView(boolean finishingInput) {
12861287
* same text field as before.
12871288
*/
12881289
public void onStartCandidatesView(EditorInfo info, boolean restarting) {
1290+
// Intentionally empty
12891291
}
12901292

12911293
/**
@@ -1455,13 +1457,15 @@ public void hideWindow() {
14551457
* for the window has occurred (creating its views etc).
14561458
*/
14571459
public void onWindowShown() {
1460+
// Intentionally empty
14581461
}
14591462

14601463
/**
14611464
* Called when the input method window has been hidden from the user,
14621465
* after previously being visible.
14631466
*/
14641467
public void onWindowHidden() {
1468+
// Intentionally empty
14651469
}
14661470

14671471
/**
@@ -1472,6 +1476,7 @@ public void onWindowHidden() {
14721476
* and {@link #getCurrentInputConnection} return valid objects.
14731477
*/
14741478
public void onBindInput() {
1479+
// Intentionally empty
14751480
}
14761481

14771482
/**
@@ -1481,6 +1486,7 @@ public void onBindInput() {
14811486
* valid objects.
14821487
*/
14831488
public void onUnbindInput() {
1489+
// Intentionally empty
14841490
}
14851491

14861492
/**
@@ -1496,6 +1502,7 @@ public void onUnbindInput() {
14961502
* session with the editor.
14971503
*/
14981504
public void onStartInput(EditorInfo attribute, boolean restarting) {
1505+
// Intentionally empty
14991506
}
15001507

15011508
void doFinishInput() {
@@ -1570,6 +1577,7 @@ public void onFinishInput() {
15701577
* <p>The default implementation here does nothing.
15711578
*/
15721579
public void onDisplayCompletions(CompletionInfo[] completions) {
1580+
// Intentionally empty
15731581
}
15741582

15751583
/**
@@ -1626,6 +1634,7 @@ public void onUpdateSelection(int oldSelStart, int oldSelEnd,
16261634
* @param focusChanged true if the user changed the focused view by this click.
16271635
*/
16281636
public void onViewClicked(boolean focusChanged) {
1637+
// Intentionally empty
16291638
}
16301639

16311640
/**
@@ -1634,6 +1643,7 @@ public void onViewClicked(boolean focusChanged) {
16341643
* The default implementation does nothing.
16351644
*/
16361645
public void onUpdateCursor(Rect newCursor) {
1646+
// Intentionally empty
16371647
}
16381648

16391649
/**
@@ -1664,6 +1674,13 @@ private void requestShowSelf(int flags) {
16641674

16651675
private boolean handleBack(boolean doIt) {
16661676
if (mShowInputRequested) {
1677+
if (isExtractViewShown() && mExtractView instanceof ExtractEditLayout) {
1678+
ExtractEditLayout extractEditLayout = (ExtractEditLayout) mExtractView;
1679+
if (extractEditLayout.isActionModeStarted()) {
1680+
if (doIt) extractEditLayout.finishActionMode();
1681+
return true;
1682+
}
1683+
}
16671684
// If the soft input area is shown, back closes it and we
16681685
// consume the back key.
16691686
if (doIt) requestHideSelf(0);

0 commit comments

Comments
 (0)