0

So I have a keyboard service like the one shown below. I haven't done much with it yet. Most of the work has gone into getting the layout in the second image to work.

The second image below shows the PopupActivity called from the keyboard service once keyboard emoticon has been clicked on the bottom left of the first image. Notice how the underlying application is not resized because the popup view is no longer a keyboard. I don't have any control of what the underlying application is going to be, but I do know that the action can be done by the keyboardview and am looking to find any way possible to replicate it. How can I adjust the underlying view, so that it shows up the same when my activity's view is expanded and when my keyboard service is expanded? Basically need that message box to appear on top of my activity layout instead of at the bottom. Again I do not have any control of the underlying Application's code (in this case Android's standard messenger application). Any help is appreciated!

Soft Keyboard as a Service Popup as an Activity

HarshMarshmallow
  • 1,007
  • 11
  • 23

2 Answers2

0

You don't use an activity. You simply change the view that your keyboard service shows to the emoticon view, and run it in your service.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • Thanks for the help. Is there any way you can help me out with a bit more direction on how to add a custom layout to a keyboardview? I was under the impression that you could only add Keyboard objects to the keyboardview. – HarshMarshmallow Feb 02 '15 at 23:17
  • The answer there is that no serious keyboard uses the KeyboardView- they role their own. KeyboardView is too confining. This especially includes the major keyboards such as Swype (where I worked), Swiftkey, and Samsung's keyboard. However if you want to use one, one workaround would be to create a layout with both a KeyboardView and your specialized emoji view in it, and toggle the visibilities on both so that only 1 is displayed at a time. – Gabe Sechan Feb 02 '15 at 23:47
  • I don't need to use the KeyboardView class. I just really didn't want to have to extend it (or the View class) and parse the keyboard/custom layout in different ways. Are there any good documentation/examples you can point me to? I saw your comment and the links on the post here: http://stackoverflow.com/questions/16768930/implementations-of-emoji-emoticon-view-keyboard-layouts, but nobody seems to be trying to run an emoji keyboard out of a service. Everything was within an application that the developer has control over. – HarshMarshmallow Feb 02 '15 at 23:57
  • THat's because if you're trying to make an emojii keyboard for your own app, making it an activity (or fragment) is a lot less painful- you don't need to implement all of the other keyboard bs, you aren't limited in your images to the built ins (you can always add an ImageSpannable to whatever), and you aren't limited by the InputConnection API. The only reason to do that is if you want to write a keyboard used in any app. – Gabe Sechan Feb 03 '15 at 00:09
  • Well thanks for the help pointing me in the right direction. I would have been working on using an activity for this for at least another day. If there is any code or documentation you could point me to, I would be in your debt. I can't seem to find any instance of anyone actually doing this. – HarshMarshmallow Feb 03 '15 at 16:34
0

To create a custom keyboard you should create a service which can listen for the keyboard calls, and extend it with InputMethodService. For a nice guide on how to create a custom keyboard, read this nice post on code.tutsplus.com.

To add a custom layout in the keyboard, you just have to inflate the custom layout in the onCreateInputView() method of the class extending InputMethodService

@Override
public View onCreateInputView() {

    RelativeLayout lR = (RelativeLayout) getLayoutInflater().inflate(R.layout.keyboard_layout, null);       
    // Do something to fetch icons or images or letters
    // lR.setOnTouchListener(this);
    return lR;
}

Here RelativeLayout is custom layout having horizontalScrollView and ScrollView in my case.

Kurt Van den Branden
  • 11,995
  • 10
  • 76
  • 85
lRadha
  • 641
  • 6
  • 16