Skip to content

Commit 1487338

Browse files
committed
Fix an issue with hardware keyboard is not displaying in issue comment
Refs pockethub#356
1 parent 611202c commit 1487338

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

app/src/main/java/com/github/mobile/ui/comment/CreateCommentActivity.java

+17
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
*/
1616
package com.github.mobile.ui.comment;
1717

18+
import static android.os.Build.VERSION.SDK_INT;
19+
import static android.os.Build.VERSION_CODES.HONEYCOMB_MR1;
1820
import static com.github.mobile.Intents.EXTRA_COMMENT;
1921
import static com.github.mobile.util.TypefaceUtils.ICON_EDIT;
2022
import static com.github.mobile.util.TypefaceUtils.ICON_WATCH;
2123
import android.content.Intent;
2224
import android.os.Bundle;
2325
import android.text.TextUtils;
26+
import android.view.View;
2427

2528
import com.actionbarsherlock.view.Menu;
2629
import com.actionbarsherlock.view.MenuItem;
@@ -52,6 +55,20 @@ protected void onCreate(Bundle savedInstanceState) {
5255
super.onCreate(savedInstanceState);
5356

5457
configureTabPager();
58+
59+
// prevent TabHost from stealing focus when using hardware keyboard
60+
if (SDK_INT >= HONEYCOMB_MR1)
61+
host.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
62+
63+
@Override
64+
public void onViewAttachedToWindow(View v) {
65+
host.getViewTreeObserver().removeOnTouchModeChangeListener(host);
66+
}
67+
68+
@Override
69+
public void onViewDetachedFromWindow(View v) {
70+
}
71+
});
5572
}
5673

5774
@Override

app/src/main/java/com/github/mobile/ui/comment/RawCommentFragment.java

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.os.Bundle;
1919
import android.text.Editable;
2020
import android.view.LayoutInflater;
21+
import android.view.MotionEvent;
2122
import android.view.View;
2223
import android.view.ViewGroup;
2324
import android.widget.EditText;
@@ -49,6 +50,14 @@ public void afterTextChanged(Editable s) {
4950
activity.invalidateOptionsMenu();
5051
}
5152
});
53+
commentText.setOnTouchListener(new View.OnTouchListener() {
54+
55+
@Override
56+
public boolean onTouch(View v, MotionEvent event) {
57+
commentText.requestFocusFromTouch();
58+
return false;
59+
}
60+
});
5261
}
5362

5463
@Override

0 commit comments

Comments
 (0)